我是 Windows Phone 7 的新手,我有一个疑问:如何在动态创建的列表框中为所选项目添加复选标记。如果用户单击列表框中的另一个项目,复选标记将其位置移动到所选项目。怎么做?我的代码如下所示: XAML 代码:
<ListBox Height="669" HorizontalAlignment="Left" Name="listBox1" VerticalAlignment="Top" Width="479" Margin="1,-3.5,0,0" SelectionChanged="listBox1_SelectionChanged" Background="White">
<ListBox.ItemTemplate>
<DataTemplate >
<Border BorderThickness="0,0,0,1.2" BorderBrush="Black" Width="480" >
<StackPanel Background="White" Name="stackpanel1" Width="480" Orientation="Horizontal">
<TextBlock Text="{Binding name}" Height="62" Width="390" FontSize="40" FontFamily="Arial" Foreground="Black" TextAlignment="Left" VerticalAlignment="Center" />
</StackPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
CS代码:
public class list
{
public string name { get; set; }
}
foreach (string s in array)
{
list obj = new list();
obj.name = s;
listBox1.Items.Add(obj);
}
请用一些代码指导我。谢谢你。