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


1 answer


If you want to disable one item inside the list, you can try this . You can do this based on your binding property. Hope it helps.



+1


source







All Articles