I have two views of WPF (Vista1.xaml and Vista2.xaml), and they are part of a MainWindow.xaml. In the Vista1.xaml i have a listview, where the user selects some items by clicking and the Vista2.xaml has a button. I want that when the user clicks on the button of Vista2.xaml, get the items that the user previously selected in the listview of Vista1.xaml.
I have class in the Vista1.xaml.cs ListViewItem_PreviewMouseLeftButtonDown method that captures the user selects the item in the listview. the code is as follows
private void ListViewItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
var item = sender as ListViewItem;
if (item != null && item.IsSelected)
{
...
}
}
I appreciate your help
Add a public property to you MainPage
that contains the data you want to pass between Vista1
and Vista2
. Then, in your event handler of Vista1, set the property and on the button click of Vista2 read the property.
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.