【问题标题】:Get all selected items in an xaml listbox?获取 xaml 列表框中的所有选定项目?
【发布时间】:2015-01-18 18:52:08
【问题描述】:

有人能告诉我如何将所有选定的项目保存在 Powershell 的 xaml 列表框中吗?当列表框选择模式设置为“扩展”时,我可以选择一个项目,但不能选择所有项目?

<ListBox Name="ListBoxRelations" Margin="1,53,0,174" FontSize="11" SelectionMode="Extended" HorizontalAlignment="Left" Width="417"/>

之后

$xaml.SelectNodes("//*[@Name]") | %{Set-Variable -Name ($_.Name) -Value $Form.FindName($_.Name)}

$WMFStruct.SelectedHosts = $ListBoxRelations.SelectedItem

以上行仅获取列表框中的第一个选定项。

【问题讨论】:

    标签: xaml powershell listbox selected


    【解决方案1】:

    通过调用$ListBoxRelations.SelectedItem,您只会得到一个项目。您需要获取$ListBoxRelations.SelectedItems

    然后你可以遍历这些项目。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-06-08
      • 1970-01-01
      • 2012-11-16
      • 1970-01-01
      • 2016-01-16
      • 2015-10-25
      • 1970-01-01
      相关资源
      最近更新 更多