I feel like I'm missing something here, but I have this datagrid which when the datasource changes, automatically redraws it self with no logical reason for it doing so.
I have the datagrid bound to a DataView property which implements INotifyPropertyChanged and I want to do some other stuff when that event is fired before calling Refresh().
So here is the datasource.
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 the binding (I call this in the constructor of the window)
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);
}
The class that updates the DataView with data from a database has access to that same instance of MainScreenDataView as the window. The instance is kept in a dictionary in a singleton.
Now I see no reason why the datagrid would refresh it self, I even tried removing the INotifyPropertyChanged stuff from MainScreenDataview and yet it keeps the same behavior.
Guess there's something I'm missing here. Default behavior somewhere that needs to be overridden or something?