Reputation: 12745
How do I achieve the following:
<ComboBox
IsEnabled="{Binding bVisibilty = AnotherCollection.Count > 0 ? true:false}"/>
I can use a converter which will be converting count to boolen, but is there a better way of doing than overdoing converter everywhere.
Upvotes: 0
Views: 86
Reputation: 2190
You can use style triggers for that like so :
<ComboBox >
<ComboBox.Style>
<Style TargetType="ComboBox">
<Style.Triggers>
<DataTrigger Binding="{Binding AnotherCollection.Count}" Value="0">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ComboBox.Style>
</ComboBox>
Obviously AnotherCollection needs to be an ObservableCollection so the UI will be notified every time item is being added\removed to it
Upvotes: 3
Reputation: 29120
You could bind to a Property on your ViewModel and put the boolean and INPC logic in the viewmodel
Upvotes: 2