【发布时间】:2017-07-19 10:09:39
【问题描述】:
我可以只通过 XAML 选择 WPF Listbox 中的所有项目吗?
我也关注了这个问题WPF Listbox and Select All,但它不起作用。 我的 XAML 代码如下:
<ListBox SelectionMode="Multiple" Name="listBox">
<ListBox.InputBindings>
<KeyBinding Command="ApplicationCommands.SelectAll" Modifiers="Ctrl" Key="A" />
</ListBox.InputBindings>
<ListBox.CommandBindings>
<CommandBinding Command="ApplicationCommands.SelectAll" />
</ListBox.CommandBindings>
<ListBoxItem>List Item 1</ListBoxItem>
<ListBoxItem>List Item 2</ListBoxItem>
<ListBoxItem>List Item 3</ListBoxItem>
<ListBoxItem>List Item 4</ListBoxItem>
<ListBoxItem>List Item 5</ListBoxItem>
</ListBox>
是否只能通过 XAMl 进行全选?
【问题讨论】:
-
XAML only 对您意味着什么,因为您使用的是
Command? -
我的意思是在 c#/vb 中的代码后面没有任何代码。我可以删除命令绑定。
-
我必须在 poweshell 中使用这个 XAML 视图。所以后面的代码在那里不起作用。