PropertyChange on bound gridview

37 views
Skip to first unread message

Ezra Schwartz

unread,
Jun 30, 2017, 6:56:25 PM6/30/17
to Eto.Forms
I fill a grid view with data.  When some of that data changes I would like the changed data to update the grid view without having to rebind the grid view.  From my understanding I should be able to do this by implementing INotifyPropertyChanged, but I can't get it to work.

When I debug, in the OnPropertyChanged function the PropertyChanged event is null so it doesn't fire.  I assume I have to do something when I bind to the grid to wire up the property changed event, but I can't figure out what that is.  Any help on what I need to do to get the PropertyChanged event to update the grid?

I bind the grid column like this:

_gridViewResults.Columns.Add(
    new GridColumn()
    {
        Width = 60, 
        HeaderText = "Instances",
        DataCell = new TextBoxCell { Binding = Binding.Property<SearchableItem, string>(o => o.Instances) }
    });


and later set the data like this:
_gridViewResults.DataStore = DoSearch(_textBoxSearch.Text);   // This returns an ObservableCollection of SearchableItems


SearchableItem implements INotifyPropertyChanged like this: 

public class SearchableItem : INotifyPropertyChanged
{
    public string Instances
    {
        get { return _instances; }
        set
        {
            _instances = value;
            OnPropertyChanged(new PropertyChangedEventArgs("Instances"));
        }
    }
    private string _instances = "";

    public event PropertyChangedEventHandler PropertyChanged;

    public void OnPropertyChanged(PropertyChangedEventArgs e)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, e);
        }
    }
}


Thanks!


Ezra Schwartz

unread,
Jul 19, 2017, 9:30:42 PM7/19/17
to Eto.Forms
Nevermind on this one, I ended up replacing these controls with an Html control in a web view.
Reply all
Reply to author
Forward
0 new messages