Skip to content

Instantly share code, notes, and snippets.

@bbrandt
Created October 9, 2018 21:16
Show Gist options
  • Select an option

  • Save bbrandt/c8038d3a49bc46a86fdbecb5b0b5e790 to your computer and use it in GitHub Desktop.

Select an option

Save bbrandt/c8038d3a49bc46a86fdbecb5b0b5e790 to your computer and use it in GitHub Desktop.
DevExpress WPF High-Performance GridControl Updates
using DevExpress.Xpf.Grid;
namespace BBrandtTX.Controls
{
public class MyGridControl : GridControl
{
public bool IsUpdateLocked
{
get
{
return this.DataProviderBase.IsUpdateLocked;
}
}
}
}
using System.Windows;
using BBrandtTX.Controls;
namespace BBrandtTX.AttachedProperties
{
public class MyGridControlIsRefreshingAttachedProperty
{
public static readonly DependencyProperty IsRefreshingProperty = DependencyProperty.RegisterAttached(
"IsRefreshing",
typeof(object),
typeof(MyGridControlIsRefreshingAttachedProperty),
new PropertyMetadata(null, UpdateIsRefreshing));
public static object GetIsRefreshing(DependencyObject obj) => obj.GetValue(IsRefreshingProperty);
public static void SetIsRefreshing(DependencyObject obj, object value) =>
obj.SetValue(IsRefreshingProperty, value);
private static void UpdateIsRefreshing(DependencyObject obj, DependencyPropertyChangedEventArgs args)
{
if (!(obj is MyGridControl grid))
{
return;
}
if (!(args.NewValue is bool isRefreshing))
{
return;
}
if (isRefreshing)
{
grid.BeginDataUpdate();
}
else if (grid.IsUpdateLocked)
{
grid.EndDataUpdate();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment