当前位置:网站首页>Managing multiple selections with MVVM - managing multiple selections with MVVM
Managing multiple selections with MVVM - managing multiple selections with MVVM
2022-07-03 17:31:00 【Zafo】
problem :
On my journey to learning MVVM I've established some basic understanding of WPF and the ViewModel pattern. In my learning MVVM In the process of , I have established a right WPF and ViewModel Some basic understanding of patterns .I'm using the following abstraction when providing a list and am interested in a single selected item. I use the following abstraction when providing lists , And interested in a single selected project .
public ObservableCollection<OrderViewModel> Orders { get; private set; }public ICollectionView OrdersView{ get { if( _ordersView == null ) _ordersView = CollectionViewSource.GetDefaultView( Orders ); return _ordersView; }}private ICollectionView _ordersView;public OrderViewModel CurrentOrder { get { return OrdersView.CurrentItem as OrderViewModel; } set { OrdersView.MoveCurrentTo( value ); } }
I can then bind the OrdersView along with supporting sorting and filtering to a list in WPF: then , I can put OrdersView With support for sorting and filtering bound to WPF List in :
<ListView ItemsSource="{Binding Path=OrdersView}" IsSynchronizedWithCurrentItem="True">
This works really well for single selection views. This is very effective for radio views .But I'd like to also support multiple selections in the view and have the model bind to the list of selected items. But I also want to support multiple choices in the view , And bind the model to the selected list .
How would I bind the ListView.SelectedItems to a backer property on the ViewModel? How to integrate ListView.SelectedItems Bound to the ViewModel Upper backer attribute ?
Solution :
Reference resources : https://stackoom.com/en/question/3Mx6边栏推荐
猜你喜欢
Simple use of unity pen XR grab
Design e-commerce spike
Automata and automatic line of non-standard design
[UE4] brush Arctic pack high quality Arctic terrain pack
设计电商秒杀
TensorBoard快速入门(Pytorch使用TensorBoard)
Internet Hospital his Management Platform source, online Inquiry, appointment Registration Smart Hospital Small program source
Play with fancy special effects. This AE super kit is for you
Hongmeng fourth training
Golang单元测试、Mock测试以及基准测试
随机推荐
Cross border e-commerce: advantages of foreign trade enterprises in overseas social media marketing
The difference between i++ and ++i: tell their differences easily
2021 ICPC regional competition (Shanghai) g.edge groups (tree DP)
Squid service startup script
[set theory] order relation: summary (partial order relation | partial order set | comparable | strictly less than | covering | hasto | total order relation | quasi order relation | partial order rela
The difference between get and post
Collection of the most beautiful graduation photos in the graduation season, collection of excellent graduation photos
Web-ui automated testing - the most complete element positioning method
[combinatorics] recursive equation (example of solving recursive equation without multiple roots | complete process of solving recursive equation without multiple roots)
1146_ SiCp learning notes_ exponentiation
免费数据 | 新库上线 | CnOpenData中国保险中介机构网点全集数据
Applet setting multi account debugging
SWM32系列教程4-端口映射及串口应用
[UE4] brush Arctic pack high quality Arctic terrain pack
STM32H7 HAL库SPI DMA发送一直处于busy的解决办法
Assembly for unloading Loadfrom() loaded assembly - unloading the assembly loaded with assembly LoadFrom()
1164 Good in C
Apache服务挂起Asynchronous AcceptEx failed.
[combinatorics] recursive equation (special solution example 1 Hannover tower complete solution process | special solution example 2 special solution processing when the characteristic root is 1)
Internet Hospital his Management Platform source, online Inquiry, appointment Registration Smart Hospital Small program source