Possible Duplicate:
How to disable a databound ListBox item based on a property value?
I have a listbox and would like to make some of the items in the listbox non-selectable based on the a field in the binding.
Ive tried setting the listboxitem.IsEnabled to false but this doesnt have teh desired effect.
Please could someone advise if this is possible.
Heres my datatemplate:
<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>
If you want to disable a single item inside the listbox you can try this. You can do it based on your binding property. Hope it helps.