Disable ListBox item selection based on WPF binding value
Possible duplicate:
How to disable a ListBox item based on property value?
I have listbox
and would like to prevent some of the items in the list from being selected based on the a field in the anchor.
I've tried setting listboxitem.IsEnabled
to false, but that doesn't have the desired effect.
Please can anyone advise if this is possible.
Here is my data template:
<DataTemplate x:Key="GridTemplate">
<StackPanel Orientation="Horizontal">
<Border Padding="{Binding EditorRow.RightBondIndent}" Width="50">
<Image x:Name="rightImg" Source="mat.png" Stretch="Fill" />
</Border>
</StackPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding EditorRow.MaterialType}" Value="Blank">
<Setter Property="IsEnabled" Value="False" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
+3
source to share