0

I have command which I am executing from my XAML (view) using below code:

<HyperlinkButton Command="{Binding DataContext.HyperlinkGoToCommand,  RelativeSource={RelativeSource AncestorType=UserControl}}" CommandParameter="ABCD">
  <TextBlock Text="ABCD" TextDecorations="Underline"/></HyperlinkButton>

Presently CommandParameter pass as string and it’s working fine but I want to pass CommandParameter as List (single item generic list) rather than as string.

4

1 回答 1

1

如果要从 (XAML) 控件中绑定集合,例如来自组合框:

<ComboBox x:name="combobox" ItemsSource="{Binding Collection}">
<HyperlinkButton Command="{Binding DataContext.HyperlinkGoToCommand}", CommandParameter="{Binding  ElementName=combobox, Path=ItemsSource}"></HyperlinkButton>

如果要从 ViewModel 绑定集合:

CommandParameter="{Binding DataContext.YourCollectionPropertyFromViewModel}" or
CommandParameter="{Binding YourCollectionFromViewModel}"

检查此答案以获取更多详细说明。

问候,

于 2013-06-13T11:29:33.687 回答