我正在尝试制作一个包含级别列表的 ListPicker 控件,每个级别旁边都有一个彩色方块。这就是我所拥有的:
<toolkit:ListPicker Grid.Row="1"
x:Name="LevelList"
Header="Level"
ItemCountThreshold="0"
FontFamily="Segoe WP Light">
<toolkit:ListPicker.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Rectangle Fill="{Binding}"
Width="43"
Height="43" />
<TextBlock Text="{Binding}"
Margin="12 0 0 0" />
</StackPanel>
</DataTemplate>
</toolkit:ListPicker.ItemTemplate>
<toolkit:ListPicker.FullModeItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal"
Margin="16 21 0 20">
<Rectangle Fill="{Binding}"
Width="43"
Height="43" />
<TextBlock Text="{Binding}"
Margin="16 0 0 0"
FontSize="43"
FontFamily="{StaticResource PhoneFontFamilyLight}" />
</StackPanel>
</DataTemplate>
</toolkit:ListPicker.FullModeItemTemplate>
</toolkit:ListPicker>
在c#部分,我有
String[] Level= { "E1", "E2", "E3", "E4", "E5"};
String[] colors = { "#FFE5AD1B", "#FF0050EF", "#FFE51400", "#FF008A00", "#FFAA00FF" };
public TolonPk()
{
InitializeComponent();
this.listaNivel.ItemsSource = Level;
this.listaNivel.ItemsSource = colors;
}
我的问题是我不知道如何将 Textblock 严格绑定到 Level String 数组并将矩形填充到颜色...我可能缺少一些简单的东西,但我似乎无法得到它.. .