Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在WPF中更改Listbox的SelectionMode?_C#_Wpf - Fatal编程技术网

C# 如何在WPF中更改Listbox的SelectionMode?

C# 如何在WPF中更改Listbox的SelectionMode?,c#,wpf,C#,Wpf,这个问题很简单,我想在我的程序中更改Listbox的SelectionMode,但我发现很难解决它。使用的是您会这样使用的 //Your three options listBox1.SelectionMode = SelectionMode.Single; listBox1.SelectionMode = SelectionMode.Extended; listBox1.SelectionMode = SelectionMode.Multiple; Xaml <Grid>

这个问题很简单,我想在我的程序中更改Listbox的SelectionMode,但我发现很难解决它。

使用的是您会这样使用的

//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>


如果您想要的不是这些,您需要更具体地说明您的确切的问题是什么。

您想如何更改它,在Xaml或代码背后,以及您遇到了什么问题?