110,534
社区成员
发帖
与我相关
我的任务
分享
<Window x:Class="WpfApplication3.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" DataContext="{Binding}">
<StackPanel>
<StackPanel.Resources>
<XmlDataProvider x:Key="MoreColors" XPath="/colors">
<x:XData>
<colors >
<color name="pink"/>
<color name="white"/>
<color name="black"/>
<color name="cyan"/>
<color name="gray"/>
<color name="magenta"/>
</colors>
</x:XData>
</XmlDataProvider>
</StackPanel.Resources>
<TextBlock Height="23" Name="textBlock1" Text="Colors:" TextWrapping="Wrap" />
<ListBox x:Name="lbColor" IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding Source={StaticResource MoreColors}, XPath=color/@name}" DataContext="{Binding Source={StaticResource MoreColors}}" DisplayMemberPath="">
</ListBox>
<!--
<TextBlock Height="23" Name="textBlock2" Text="You selected Color: " />
<TextBlock Height="23" Name="textBlock3" Text="{Binding ElementName=lbColor, Path=SelectedItem.Content}" Background="{Binding ElementName=lbColor, Path=SelectedItem.Content}"></TextBlock>
<TextBox Height="23" Name="textBox1" Text="{Binding ElementName=lbColor, Path=SelectedItem.Content, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
-->
</StackPanel>
</Window>