WPat datagrid is updated when it should not

I feel that something is missing here, but I have this data file, which when I change the data source automatically redraws it myself, without any logical reason for this.

I have a datagrid attached to a DataView property that implements INotifyPropertyChanged, and I want to do some other things when this event fires before Refresh () is called.

So here is the data source.

public class MainScreenDataView : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;
    void OnPropertyChanged(string name)
    {
        PropertyChangedEventHandler handler = PropertyChanged;
        if (handler != null)
        {
            handler(this, new PropertyChangedEventArgs(name));
        }
    }

    DataView _dataview;

    public DataView GetDataView
    {
        get { return _dataview; }
        set
        {
            _dataview = value;
            OnPropertyChanged("GetDataView");
        }
    }
    public MainScreenDataView()
    {
    }
}

And binding (I call this in the window constructor)

    public void MakeData()
    {
        MiddleMan midman = MiddleMan.Instance; 
        midman.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(midman_PropertyChanged); //unrelated event for error messages
        midman.InstantiateAll();


        Binding bind = new Binding();
        bind.Source = midman.GetDict["contact"].GetDataView; //GetDict is a dictionary that holds instances of MainScreenDataView
        bind.UpdateSourceTrigger = UpdateSourceTrigger.Explicit;
        DG_Contacts.SetBinding(BetterDataGrid.ItemsSourceProperty, bind);
    }

A class that updates a DataView with data from the database has access to the same instance of MainScreenDataView as a window. The instance is stored in the dictionary in singleton mode.

, datagrid , INotifyPropertyChanged MainScreenDataview, .

, . - - ?

+3
1

. . UpdateSourceTrigger.Explicit , , MainScreenDataView.GetDataView, DataGrid.ItemSource. DataGrid.ItemSource - target.

INotifyPropertyChanged MainScreenDataView , , . , GetDataView " ".

, , , , DataView.CollectionChanged , .

, , , DataView , .

+2

All Articles