Reputation: 353
I have a ListView, which ListViewItems have buttons, defined in ListView.ItemTemplate. How can I select a ListViewItem upon such button's Click event? I know how to make that in WPF, but can't figure for UWP, since UWP Styles don't support triggers.
Upvotes: 0
Views: 1007
Reputation: 9990
In the button clicked event add:
listView.SelectedItem = ((FrameworkElement)sender).DataContext;
Upvotes: 1
Reputation: 2051
You will have to use a delegate command
The following example shows you how to accomplish this
https://code.msdn.microsoft.com/windowsapps/How-to-bind-command-to-a-299f7759
but a simplier example is to use template 10 which has a delegate command already created for you.
https://github.com/Windows-XAML/Template10/wiki/MVVM#delegatecommand
To learn more on template 10 go to
https://mva.microsoft.com/en-us/training-courses/getting-started-with-template-10-16336
Upvotes: 0