예제 #1
0
        public static IDisposable Track(this DataGrid dataGrid, DataGridSetting dataGridSetting)
        {
            EventHandler <DataGridColumnEventArgs> columnDisplayIndexChanged =
                (sender, args) => DataGridColumnDisplayIndexChanged(dataGridSetting, args);
            DataGridSortingEventHandler dataGridSortingChanged =
                (sender, args) => DataGridSorting(dataGridSetting, args);

            dataGrid.ColumnDisplayIndexChanged += columnDisplayIndexChanged;
            dataGrid.Sorting += dataGridSortingChanged;

            var notifiers = new List <PropertyChangeNotifier>();

            foreach (var column in dataGrid.Columns)
            {
                EventHandler ev       = (sender, x) => WidthChanged(column, dataGridSetting);
                var          notifier = new PropertyChangeNotifier(column, DataGridColumn.ActualWidthProperty);
                notifier.ValueChanged += ev;
                notifiers.Add(notifier);
            }

            return(Disposable.Create(() => {
                dataGrid.ColumnDisplayIndexChanged -= columnDisplayIndexChanged;
                dataGrid.Sorting -= dataGridSortingChanged;
                notifiers.DoForEach(
                    notifier => notifier.Dispose());
            }));
        }
예제 #2
0
 public override void Dispose()
 {
     _notifyName.Dispose();
     _notifyRed.Dispose();
     _notifyGreen.Dispose();
     _notifyBlue.Dispose();
     base.Dispose();
 }
        protected override void OnDetaching()
        {
            AssociatedObject.Loaded           -= AssociatedObjectLoaded;
            AssociatedObject.PreviewTextInput -= AssociatedObjectPreviewTextInput;
            AssociatedObject.PreviewKeyDown   -= AssociatedObjectPreviewKeyDown;

            DataObject.RemovePastingHandler(AssociatedObject, Pasting);

            textPropertyNotifier?.Dispose();

            base.OnDetaching();
        }
        private IDisposable TrackDataGrid(DataGrid dataGrid)
        {
            dataGrid.ColumnDisplayIndexChanged += DataGridColumnDisplayIndexChanged;
            dataGrid.Sorting += DataGridSorting;

            var notifiers = new List <PropertyChangeNotifier>();

            foreach (var column in dataGrid.Columns)
            {
                EventHandler ev       = (sender, x) => WidthChanged(column);
                var          notifier = new PropertyChangeNotifier(column, DataGridColumn.ActualWidthProperty);
                notifier.ValueChanged += ev;
                notifiers.Add(notifier);
            }

            return(Disposable.Create(() =>
            {
                dataGrid.ColumnDisplayIndexChanged -= DataGridColumnDisplayIndexChanged;
                dataGrid.Sorting -= DataGridSorting;
                notifiers.DoForEach(
                    notifier => notifier.Dispose());
            }));
        }