Mục lục bài viết
Cập Nhật: 2021-12-27 16:08:04,Bạn Cần tương hỗ về Binding listbox wpf mvvm. You trọn vẹn có thể lại phản hồi ở cuối bài để Admin được tương hỗ.
How do I bind a view model property to the ListBox.SelectedItem property?
I have created a simple MVVM demo to try to figure this one out. My view model has these properties:
private ObservableCollection p_DisneyCharacters;
public ObservableCollection DisneyCharacters
get return p_DisneyCharacters;
set
p_DisneyCharacters = value;
base.FirePropertyChangedEvent(“DisneyCharacters”);
private DisneyCharacter p_SelectedItem;
public DisneyCharacter SelectedItem
get return p_SelectedItem;
set
p_SelectedItem = value;
base.FirePropertyChangedEvent(“SelectedItem”);
I want to bind the SelectedItem property to the item selected in the list box. Here is the XAML for the list box:
Here is my problem: The view model SelectedItem property isn’t being updated when I change the selection in the list box.
I did a test where I temporarily replaced the view model SelectedItem property with a SelectedIndex property, and I bound that to the ListBox.SelectedIndex property. That property updated fine–it’s just the SelectedItem property that I can’t get to work.
So, how do I fix the SelectedItem binding? Thanks for your help.
See Question&Answers more detail:os
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视
Reply
1
0
Chia sẻ
– Một số từ khóa tìm kiếm nhiều : ” Review Binding listbox wpf mvvm tiên tiến và phát triển nhất , Chia Sẻ Link Tải Binding listbox wpf mvvm “.
Quý quý khách trọn vẹn có thể để lại phản hồi nếu gặp yếu tố chưa hiểu nghen.
#Binding #listbox #wpf #mvvm