问题很简单,我想在我的程序中更改Listbox的SelectionMode,但我发现它很难解决。
答案 0 :(得分:2)
ListBox.SelectionMode
使用您将使用的System.Windows.Controls.SelectionMode Enumeration
。
//Your three options
listBox1.SelectionMode = SelectionMode.Single;
listBox1.SelectionMode = SelectionMode.Extended;
listBox1.SelectionMode = SelectionMode.Multiple;
<强>的Xaml 强>
<Grid>
<ListBox Height="100" SelectionMode="Extended" HorizontalAlignment="Left" Margin="10,10,0,0" Name="listBox1" VerticalAlignment="Top" Width="120" />
<ListBox Height="100" SelectionMode="Multiple" HorizontalAlignment="Left" Margin="147,10,0,0" Name="listBox2" VerticalAlignment="Top" Width="120" />
<ListBox Height="100" SelectionMode="Single" HorizontalAlignment="Left" Margin="284,10,0,0" Name="listBox3" VerticalAlignment="Top" Width="120" />
</Grid>
如果你想要的不是这个,你需要更具体地解决 Exact 问题。