Thanks a lot for your help. This works well and is a lot cleaner than what i tried to do.. However, i have one more question:
In our application we display the same instance of a grid in various Content controls. Example: The grid is sometimes shown on the bottom and sometimes at the top, depending on the users preferences. It is crucial, that it is the same instance of the grid as the column settings (filtering, ordering etc) must remain the same. Furthermore, depending on the position the grid is readonly or in edit mode. Therefore, whenever we put the grid in a different content control, the style selector checks must be performed again for all visible rows.
GridCheckStyle : StyleSelector
item, DependencyObject container)
var row = container
var grid = row.GridViewDataControl;
var anf = item
sender, System.Windows.RoutedEventArgs e)
// ensure that style selector is refreshed for every visible row
//works but reloads everything
// this.DataGrid.ResetTheme(); // does not work
// this.DataGrid.ApplyTemplate(); // does not work
// this.DataGrid.UpdateLayout(); // does not work
To solve this issue, I just Rebind all the items. However, this triggers an unnecessary server request which costs quite a lot of time.
Is there a way to avoid that unnecessary request (triggerred by Datarid.Rebind())? I just need a way to perform all the style select on all visible rows via code behind.
Thanks in advance.