This article is a mirror article of machine translation, please click here to jump to the original article.

View: 15924|Reply: 0

[WPF] WPF ListView gets values that require data binding

[Copy link]
Posted on 4/25/2019 8:22:27 AM | | |
Before writing the wpf listview, what was looked at wassource code of winform,It is not right to use WPF with a winform mindset. If usedWinForm assigns a value to the WPF ListView, selects data in the fetch WPF ListView, and converts the type

cijitiezi. SelectedItem will be an anonymous type and cannot be converted to the corresponding class.WPF is data-driven interface,ListView is just a form of displaying a collection of data.ListView is bound to the data collection you want to display via the ItemSource property.Your goal should be your dataset, not the ListView.

First, initialize the data collection
In the binding data set, it is ready to use.
It turns out that the item type selected by Listview is the type we bind to it, that is, if we bind class A to a control, the selected item is an instance of class A.






Previous:Docker in Practice
Next:Two very unfriendly IP segments 220.243.135.* 220.243.136.*
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com