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);
midman.InstantiateAll();
Binding bind = new Binding();
bind.Source = midman.GetDict["contact"].GetDataView;
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, .
, . - - ?