Reputation: 9983
I have a button that is enabled only when an item is selected in one of my list controls:
<Style TargetType="{x:Type Button}">
<Style.Triggers>
<DataTrigger Binding="{Binding SelectedIndex, ElementName=ganttChartTaskListView}" Value="-1">
<Setter Property="IsEnabled" Value="False" />
</DataTrigger>
</Style.Triggers>
</Style>
I have to perform somewhat similar binding, however, in this new case I want to only have the button enabled when the SelectedIndex >= 1 (!= -1 && != 0)
How would I go about doing this in xaml?
Upvotes: 1
Views: 925
Reputation: 30830
Create an IValueConverter that returns True/False based on your condition. And change your Trigger to following:
<DataTrigger Binding="{Binding SelectedIndex, ElementName=ganttChartTaskListView, Converter={StaticResource MyConverter}}" Value="False">
<Setter Property="IsEnabled" Value="False" />
</DataTrigger>
Upvotes: 3