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.
If you want to bind collection from (XAML) control for an example from combobox:
<ComboBox x:name="combobox" ItemsSource="{Binding Collection}">
<HyperlinkButton Command="{Binding DataContext.HyperlinkGoToCommand}", CommandParameter="{Binding ElementName=combobox, Path=ItemsSource}"></HyperlinkButton>
If you want to bind collection from ViewModel:
CommandParameter="{Binding DataContext.YourCollectionPropertyFromViewModel}" or
CommandParameter="{Binding YourCollectionFromViewModel}"
Check this answer for more detail explanations.
Regards,
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.