Please put me out of my misery:
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="IsEnabled" Value="{Binding MyBoolField}" />
</Style>
</ListView.ItemContainerStyle>
Where MyBoolField
is a property available on each item in the ListView
's assigned ItemsSource
, and is of course of type bool
.
The desired behaviour is that the IsEnabled
property of each ListViewItem
is bound to the MyBoolField
property of the object it contains (an element from the ListView
's ItemsSource
). The example above however pays no attention to this binding and is always true
.
If I set the value to false
statically, the item becomes disabled as expected.
I can only assume this is an issue of scoping, or a restriction on the use of bindings in this particular scenario, however I am unable to find any documentation to support this.
Perhaps it is useful to know that bindings set up in the DataTemplate
assigned to this ListView
's ItemTemplate
all work okay, so the problem is hopefully not that fundamental/stupid.
Points from the Comments
- There is no relevant output in the debug 'Output' window.
- Binding the
MyBoolField
property elsewhere works fine, as such the underlying data source is providing a Boolean value correctly and this seems to be solely an issue of binding it in this context.