I got a listbox with listing down item, each item is stackpanel with an icon and description text.
<ListBox x:Name="lstSlectionTools"
SelectedIndex="2"
SelectionChanged="ListBox1_SelectionChanged">
<StackPanel Orientation="Horizontal" >
<ContentControl Template="{StaticResource Icon1}"/>
<TextBlock Margin="3,0,0,0" Text="Item1" />
</StackPanel>
<StackPanel Orientation="Horizontal" >
<ContentControl Template="{StaticResource Icon2}"/>
<TextBlock Margin="3,0,0,0" Text="Item2" />
</StackPanel>
<StackPanel Orientation="Horizontal" >
<Con开发者_如何转开发tentControl Template="{StaticResource Icon13}"/>
<TextBlock Margin="3,0,0,0" Text="Item3" />
</StackPanel>
<StackPanel Orientation="Horizontal" >
<ContentControl Template="{StaticResource Icon4}"/>
<TextBlock Margin="3,0,0,0" Text="Item4" />
</StackPanel>
</ListBox>
I want to show the selected item icon something like:
<ContentControl x:Name="selectTool"
Template="{Binding SelectedItem.Template, ElementName=lstSlectionTools}"" />
I am unable to figure out how to bind selected item (i.e. stackpanel first child's template to the selectTool's template.
The Binding.Path
in this case would be SelectedItem.Children[0].Template
.
精彩评论