相关疑难解决方法(0)

ObservableCollection没有注意到它中的Item何时发生变化(即使使用INotifyPropertyChanged)

有谁知道为什么这段代码不起作用:

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等等,它除了这个问题以外的所有其他工作..

c# observablecollection inotifypropertychanged

158
推荐指数
10
解决办法
16万
查看次数

在有界数据发生更改后重新排序WPF DataGrid

我正在寻找一种方式来重新梳理DataGrid当基础数据已经改变.

(设置非常标准:DataGrid的ItemSource属性绑定到ObservableCollection;列是DataGridTextColumns; DataGrid内的数据对ObservableCollection内部的更改做出正确反应;使用鼠标单击时排序工作正常)

有任何想法吗 ?

c# data-binding wpf datagrid collectionviewsource

28
推荐指数
3
解决办法
3万
查看次数

无法在CheckComboBox中设置所选项的初始状态

我正在尝试使用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)

wpf xceed wpf-extended-toolkit

10
推荐指数
1
解决办法
1433
查看次数

可观察集合在MVVM中更改属性时通知

我试图将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

9
推荐指数
1
解决办法
1万
查看次数