Below is the XAML i currently have. I want to emulate a tree by having a toggle button and a listview will bind it’s visibility to the toggle buttons chcked state. Problem is, I need to bind to a child of a sibling. Is this even possible?
this code doesn’t work becuase the toggle isn’t an ancestor.
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<ToggleButton Name="tglBtn">+</ToggleButton>
<TextBlock>test</TextBlock>
</StackPanel>
<ListView Visibility="{Binding RelativeSource={RelativeSource AncestorType={x:Type ToggleButton}}, Path=IsChecked, Converter={StaticResource boolToVis}}">
<ListView.View>
<GridView>
<GridViewColumn Header="Thread" DisplayMemberBinding="{Binding thread_name}" />
<GridViewColumn Width="Auto" Header="Created" DisplayMemberBinding="{Binding thread_created}" />
<GridViewColumn Width="Auto" Header="Modified" DisplayMemberBinding="{Binding last_modified}" />
</GridView>
</ListView.View>
</ListView>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
You can use ElementName Binding to access the ToggleButton