internal void UpdateSelectionForegroundBrush() { // If SelectionBorderVisiblity is Visible, bind VirtualizingCellsControl Foreground with SelectionForegroundBrush if (this.SelectionBorderVisiblity == Visibility.Visible) { var dataGrid = this.GetRowGenerator().Owner as SfDataGrid; // Assign SelectionForegroundBrush to Foreground when the SelectionForegroundBrush is set explicity of AddNewRowControl doesn't equal with SfDataGrid.GridSelectionForegroundBrush. if (this.SelectionForegroundBrush != SfDataGrid.GridSelectionForgroundBrush) { this.Foreground = this.SelectionForegroundBrush; } // SelectionForegroundBrush is not to set explicitly to AddNewRowControl, then assign SfDataGrid SelectionForegroundBrush to Foreground. // Otherwise, Foreground Brush is set as default value of AddNewRowControl. else if (dataGrid.SelectionForegroundBrush != SfDataGrid.GridSelectionForgroundBrush) { this.Foreground = dataGrid.SelectionForegroundBrush; } #if UWP else if (ForegroundProperty.GetMetadata(typeof(FrameworkElement)).DefaultValue == this.Foreground) { this.Foreground = SfDataGrid.GridSelectionForgroundBrush; } #endif } else { this.ClearValue(VirtualizingCellsControl.ForegroundProperty); } }
private static void OnSelectionBorderVisiblityChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { var gridCell = obj as GridCell; // If SelectionBorderVisiblity is Visible, bind GridCell Foreground with SelectionForegroundBrush if (args.NewValue.Equals(Visibility.Visible)) { if (gridCell.SelectionForegroundBrush != SfDataGrid.GridSelectionForgroundBrush) { gridCell.Foreground = gridCell.SelectionForegroundBrush; } else if (SfDataGrid.GridSelectionForgroundBrush != gridCell.ColumnBase.Renderer.DataGrid.SelectionForegroundBrush) { gridCell.Foreground = gridCell.ColumnBase.Renderer.DataGrid.SelectionForegroundBrush; } #if UWP else if (ForegroundProperty.GetMetadata(typeof(FrameworkElement)).DefaultValue == gridCell.Foreground) { gridCell.Foreground = SfDataGrid.GridSelectionForgroundBrush; } #endif } else { gridCell.ClearValue(GridCell.ForegroundProperty); } }
static TextBlock() { TextProperty.OverrideMetadata(typeof(TextBlock), new FrameworkPropertyMetadata( (string)Controls.TextBlock.TextProperty.GetMetadata(typeof(Controls.TextBlock)).DefaultValue, (o, e) => (o as TextBlock).OnTextChanged(e.NewValue as string))); ForegroundProperty.OverrideMetadata(typeof(TextBlock), new FrameworkPropertyMetadata( (Brush)ForegroundProperty.GetMetadata(typeof(Controls.TextBlock)).DefaultValue, (o, e) => (o as TextBlock).OnForegroundChanged(e.NewValue as Brush))); FontSizeProperty.OverrideMetadata(typeof(TextBlock), new FrameworkPropertyMetadata( (double)FontSizeProperty.GetMetadata(typeof(Controls.TextBlock)).DefaultValue, (o, e) => (o as TextBlock).OnFontSizeChanged((double)e.NewValue))); }
protected void UpdatedSelectionState(bool canApplyDefaultState = true) { var isSelected = this.IsSelected; var isFocused = this.IsFocusedRow; if (isSelected) { this.UpdateIndentMargin(); VisualStateManager.GoToState(this, "Selected", false); } else if (isFocused) { VisualStateManager.GoToState(this, "Focused", false); } else if (canApplyDefaultState) { VisualStateManager.GoToState(this, "Unselected", false); } if (isSelected) { var treeGrid = DataRow.TreeGrid; if (SelectionForeground != SfTreeGrid.GridSelectionForgroundBrush) { Foreground = SelectionForeground; } else if (treeGrid.SelectionForeground != SfTreeGrid.GridSelectionForgroundBrush) { Foreground = treeGrid.SelectionForeground; } #if UWP else if (ForegroundProperty.GetMetadata(typeof(FrameworkElement)).DefaultValue == Foreground) { Foreground = SfTreeGrid.GridSelectionForgroundBrush; } #endif } else { ClearValue(TreeGridRowControl.ForegroundProperty); } }