ComboBox
Button
StackPanel
Image
TextBlock
Ellipse
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib"> <Page.Resources> <!-- a string array --> <x:Array x:Key="myarray1" Type="{x:Type sys:String}"> <sys:String>Item 1</sys:String> <sys:String>Item 2</sys:String> <sys:String>Item 3</sys:String> <sys:String>Item 4</sys:String> </x:Array> <!-- an array of other type of content --> <x:Array x:Key="myarray2" Type="{x:Type StackPanel}"> <StackPanel> <Ellipse Width="16" Height="16" Fill="Red"/> <TextBlock Text="Item 1"/> </StackPanel> <StackPanel> <Ellipse Width="16" Height="16" Fill="Blue"/> <TextBlock Text="Item 2"/> </StackPanel> <StackPanel> <Ellipse Width="16" Height="16" Fill="Green"/> <TextBlock Text="Item 3"/> </StackPanel> </x:Array> </Page.Resources> <!-- in the DataContext, if I change myarray2 into myarray1 everything is fine --> <WrapPanel DataContext="{Binding Source={StaticResource myarray2}, Path=.}"> <!-- bind combo's items to the DataContext --> <ComboBox ItemsSource="{Binding}" IsSynchronizedWithCurrentItem="true" Margin="5"/> <!-- bind button's content to the combo selected item --> <Button Content="{Binding /}" Margin="5" /> </WrapPanel> </Page>
<Button Content="{Binding Path=Text}" Margin="5"/>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)