Created
October 9, 2018 21:16
-
-
Save bbrandt/c8038d3a49bc46a86fdbecb5b0b5e790 to your computer and use it in GitHub Desktop.
DevExpress WPF High-Performance GridControl Updates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using DevExpress.Xpf.Grid; | |
| namespace BBrandtTX.Controls | |
| { | |
| public class MyGridControl : GridControl | |
| { | |
| public bool IsUpdateLocked | |
| { | |
| get | |
| { | |
| return this.DataProviderBase.IsUpdateLocked; | |
| } | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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