I’ve just started testing the water with WPF and I’m trying to bind the expanded property of an expander and the selected property of a listview item together so that when a list view item is selected the expander expands or going down another road trying to set the listview item to selected on expand of the expander
so far I’ve got
<ListView HorizontalAlignment="Stretch" Name="listView1" VerticalAlignment="Stretch" SelectionMode="Single" >
<ListView.Resources>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="IsSelected" Value="{Binding Path=IsExpanded, Mode=TwoWay}"/>
</Style>
</ListView.Resources>
<ListView.ItemTemplate>
<DataTemplate>
<Expander>
<TextBlock Text="{Binding Name}"></TextBlock>
</Expander>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
But I can’t figure out how to reference the expander in the binding. Any help or a nudge in the right direction would be appreciated.
Thanks
Well..
You can not connect listboxitem with its own template … Because basically they do not know… That would not work here:
You also can not fire a trigger of the expander, because setters do not accept binding ..
The answer is this:
If you prefer you can use the binding, mode = OneWayToSource, depending on your needs ..