dataTemplate から listBoxItem を取得して、選択した項目をラベルに表示する場合、listBox から Binding を使用するにはどうすればよいですか
これは私のコードです:
<Window.Resources>
<XmlDataProvider x:Key="data">
<x:XData>
<colors xmlns="">
<color name="yellow"/>
<color name="red"/>
<color name="blue"/>
<color name="black"/>
<color name="pink"/>
<color name="brown"/>
</colors>
</x:XData>
</XmlDataProvider>
<DataTemplate x:Key="temp">
<StackPanel Orientation="Vertical">
<Label Content="{Binding XPath=@name}"/>
</StackPanel>
</DataTemplate>
</Window.Resources>
<StackPanel Orientation="Vertical">
<ListBox Name="lblColor" ItemsSource="{Binding Source={StaticResource data}, XPath=colors/color}"
ItemTemplate="{StaticResource temp}" Background="Transparent" SelectedIndex="0"></ListBox>
<Label Content="your choice is :"></Label>
<Label ></Label>
</StackPanel>
選択したアイテムを最後のラベルのコンテンツに表示したい...助けてくれてありがとう。