In WPF and xaml i want to have a combo box with items like list0 - list5
Now, when i select that item or index i want it to display in a list box.
I want it to populate the list box with those words below and the correct index like if i select the first one "List0" it displays in the list box:
foo0
bar0
baz0
toto0
tintin0
开发者_如何学Go
So, when i select "list3" in the combobox
It will display those words with the right index thats selected... can this be done with xaml?
If this cant be done in xaml can i do this in C# with xaml project?
here is a pic of what i want to accomplish!
Working XAML-Only example:
xmlns:sys="clr-namespace:System;assembly=mscorlib"
<StackPanel>
<ComboBox Name="cb" SelectedIndex="0">
<ComboBoxItem Content="List0"/>
<ComboBoxItem Content="List1"/>
<ComboBoxItem Content="List2"/>
<ComboBoxItem Content="List3"/>
<ComboBoxItem Content="List4"/>
<ComboBoxItem Content="List5"/>
</ComboBox>
<ListBox>
<ListBox.ItemsSource>
<x:Array Type="{x:Type sys:String}">
<sys:String>foo</sys:String>
<sys:String>bar</sys:String>
<sys:String>baz</sys:String>
<sys:String>toto</sys:String>
<sys:String>tintin</sys:String>
</x:Array>
</ListBox.ItemsSource>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0}{1}">
<Binding Mode="OneWay"/>
<Binding Path="SelectedIndex" ElementName="cb"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
精彩评论