Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable selection of an ListBox item based on binding value WPF [duplicate]

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>
like image 503
user589195 Avatar asked Dec 22 '25 16:12

user589195


1 Answers

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.

like image 180
Srinivas Avatar answered Dec 24 '25 06:12

Srinivas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!