We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Binding feature question

From looking at previous posts, data binding support is not built-in to the WPF grid. When the feature is implemented, will it have the capability of automatically populating the grid columns and values based on the public properties of the object/interface? I have worked with other grid where this was possible and it made managing the data as easy as managing an IList<>.



4 Replies

AD Administrator Syncfusion Team August 15, 2008 04:02 PM UTC

Yes, our databinding support will handle these tasks for you when it becomes available.

One comment is that such support (in a minimal form) is fairly straight forward to do with our WPF GridControl because of its virtual support. Here is a minimal sample showing how you can use a virtual grid to display an IList<> source with the virtual events.
http://www.syncfusion.com/support/user/uploads/BindingHelperSample_c214a724.zip

When we publish our databinding support, it will be much more fully featured than this simple sample.




JY Jeff Yang August 18, 2008 05:23 PM UTC

Thanks for the example. So another question, if I want the grid to update whenever I update items in my IList<>, would the correct way be to call InvalidateCell then InvalidateVisual (as described in the documentation comments for the InvalidateCell method? I want to make sure that I am doing as little repainting as possible. Lastly, I see that all InvalidateVisual overloads take in an object which represents the cell/cell range to invalidate. Is there anyway to get at already instantiated objects representing the cell cooridinates. The reason I'm asking is because of the frequency of updates to my grid, new-ing an object everytime I update is going to increase the time spent in GC




JY Jeff Yang August 18, 2008 05:25 PM UTC

"...I see that all InvalidateVisual overloads take in an object..."

should be:

"...I see that all InvalidateCell overloads take in an object..."



AD Administrator Syncfusion Team August 18, 2008 06:16 PM UTC

You will have to create a new CellSpanInfo object for each change unless you know explicitly the cells that change and can somehow cache CellSpanInfo objects and simple recall them from your cache.

In that sample, if you change the List to BindingList and makes sure your raise the ListChanged event somehow when values change, then you can use code like this to trigger the screen refreshes.

void list_ListChanged(object sender, ListChangedEventArgs e)
{
IList list = sender as IList;
switch (e.ListChangedType)
{
case ListChangedType.ItemChanged:
if (e.NewIndex > -1 && e.NewIndex < list.Count)
{
grid.InvalidateCell(new CellSpanInfo(e.NewIndex + 1, 1, e.NewIndex + 1, grid.Model.ColumnCount));
grid.InvalidateVisual(false);
}
break;
default:
break;
}
}




Loader.
Live Chat Icon For mobile
Up arrow icon