有谁知道为什么这段代码不起作用:
public class CollectionViewModel : ViewModelBase {
public ObservableCollection<EntityViewModel> ContentList
{
get { return _contentList; }
set
{
_contentList = value;
RaisePropertyChanged("ContentList");
//I want to be notified here when something changes..?
//debugger doesn't stop here when IsRowChecked is toggled
}
}
}
public class EntityViewModel : ViewModelBase
{
private bool _isRowChecked;
public bool IsRowChecked
{
get { return _isRowChecked; }
set { _isRowChecked = value; RaisePropertyChanged("IsRowChecked"); }
}
}
Run Code Online (Sandbox Code Playgroud)
ViewModelBase包含所有东西RaisePropertyChanged等等,它除了这个问题以外的所有其他工作..
我正在寻找一种方式来重新梳理我DataGrid当基础数据已经改变.
(设置非常标准:DataGrid的ItemSource属性绑定到ObservableCollection;列是DataGridTextColumns; DataGrid内的数据对ObservableCollection内部的更改做出正确反应;使用鼠标单击时排序工作正常)
有任何想法吗 ?
我正在尝试使用Xceed CheckComboBox,除了一个小问题之外它运行良好.最初加载CheckComboBox时,CheckComboBox的ToggleButton部分中正确显示所选项List,但不检查表示这些项的复选框.这是我正在使用的代码
XAML
<xctk:CheckComboBox x:Name="_combo" Grid.Row="2" Grid.Column="1"
ItemsSource="{Binding RoomFacilities}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
DisplayMemberPath="FacilityName"
SelectedItemsOverride="{Binding SelectedFaclities}"
/>
Run Code Online (Sandbox Code Playgroud)
查看模型
public class RoomBandUpdateViewModel : Screen, IHandle<RecordChanged<RoomFacility>>,
IHandle<RecordDeleted<RoomFacility>> {
private ObservableCollection<RoomFacility> _roomFacilities;
public ObservableCollection<RoomFacility> RoomFacilities {
get { return _roomFacilities; }
set { _roomFacilities = value; NotifyOfPropertyChange(() => RoomFacilities); }
}
private ObservableCollection<RoomFacility> _selectedFacilities;
public ObservableCollection<RoomFacility> SelectedFaclities {
get { return _selectedFacilities; }
set { _selectedFacilities = value; NotifyOfPropertyChange(() => SelectedFaclities); }
}
protected override void OnActivate() {
SelectedFaclities = new ObservableCollection<RoomFacility>(RoomBand.Facilities);
RoomFacilities …Run Code Online (Sandbox Code Playgroud) 我试图将observable集合绑定到DataGrid,我想在datagrid中编辑任何行时通知.我的代码适用于添加或删除记录时的通知,但是在编辑记录时没有通知.如果这是使用MVVM中的可观察集合进行绑定的正确方法,请告诉我,以及我是否缺少某些内容.提前致谢.
public class studentViewModel : INotifyPropertyChanged
{
#region constructor
public studentViewModel()
{
_student = new studentModel();
myCollection = new ObservableCollection<studentModel>();
myCollection.Add(_student);
myCollection.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(myCollection_CollectionChanged);
}
void myCollection_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
//throw new NotImplementedException();
System.Windows.MessageBox.Show(e.Action.ToString());
}
#endregion
#region properties
studentModel _student;
ObservableCollection<studentModel> _myCollection;
public ObservableCollection<studentModel> myCollection
{
get { return _myCollection; }
set
{
if (_myCollection != value)
{
_myCollection = value;
raisePropertyChange("myCollection");
}
}
}
public int rollNo
{
get { return _student.rollNo; }
set
{
if (value …Run Code Online (Sandbox Code Playgroud) observablecollection mvvm inotifycollectionchanged inotifypropertychanged