private void UnloadDisplayUIElement(FrameworkElement uiElements, TreeDataColumnBase column) { D uiElement = null; if (!(column.TreeGridColumn.hasCellTemplate || column.TreeGridColumn.hasCellTemplateSelector)) { if (!UseOnlyRendererElement && uiElements is TreeGridCell) { uiElement = (uiElements as TreeGridCell).Content as D; } else { uiElement = uiElements as D; } } if (uiElement != null) { UnwireDisplayUIElement(uiElement); if (AllowRecycle) { DisplayRecycleBin.Enqueue(this, uiElement); } } if (!UseOnlyRendererElement && uiElements is TreeGridCell) { ResetGridCell(uiElements as TreeGridCell); } else if (uiElement.Parent is Panel) { (uiElement.Parent as Panel).Children.Remove(uiElement); } }
public override void OnUpdateEditBinding(TreeDataColumnBase dataColumn, TreeGridHeaderCell element, object dataContext) { TreeGridColumn column = dataColumn.TreeGridColumn; // WPF-37159 - No need to clone the column. So below line is commented. //#if WPF // if (TreeGrid != null && !TreeGrid.IsLoaded) // column = column.Clone() as TreeGridColumn; //#endif element.ClearValue(TreeGridHeaderCell.ContentProperty); element.Column = column; if (column.HeaderText == null) { column.HeaderText = column.MappingName; } element.SetValue(ContentControl.ContentProperty, column.HeaderText); //We need bind the HorizontalHeaderContentAlignment value if only column has HorizontalHeaderContentAlignment value if (column.ReadLocalValue(TreeGridColumn.HorizontalHeaderContentAlignmentProperty) != DependencyProperty.UnsetValue) { element.SetValue(Control.HorizontalContentAlignmentProperty, column.HorizontalHeaderContentAlignment); } else { element.ClearValue(Control.HorizontalContentAlignmentProperty); } element.Update(); element.DataContext = column; }
/// <summary> /// Initialize the binding for editor control of corresponding column. /// </summary> /// <param name="dataColumn">Specifies the dataColumn which contain TreeGridColumn, RowColumnIndex</param> /// <param name="uiElement">Specifies the data context of the particular row</param> /// <param name="dataContext">Specifies the data context of the particular row</param> public override void OnInitializeEditElement(TreeDataColumnBase dataColumn, E uiElement, object dataContext) { TreeGridColumn column = dataColumn.TreeGridColumn; var textPadding = new Binding { Path = new PropertyPath("Padding"), Mode = BindingMode.OneWay, Source = column }; uiElement.SetBinding(Control.PaddingProperty, textPadding); var textAlignBind = new Binding { Path = new PropertyPath("TextAlignment"), Mode = BindingMode.TwoWay, Source = column }; uiElement.SetBinding(TextBox.TextAlignmentProperty, textAlignBind); var textWrappingBinding = new Binding { Path = new PropertyPath("TextWrapping"), Mode = BindingMode.TwoWay, Source = column }; uiElement.SetBinding(TextBox.TextWrappingProperty, textWrappingBinding); var verticalContentAlignment = new Binding { Path = new PropertyPath("VerticalAlignment"), Mode = BindingMode.TwoWay, Source = column }; uiElement.SetBinding(Control.VerticalContentAlignmentProperty, verticalContentAlignment); #if WPF var textDecorations = new Binding { Path = new PropertyPath("TextDecorations"), Mode = BindingMode.TwoWay, Source = column }; uiElement.SetBinding(TextBox.TextDecorationsProperty, textDecorations); #endif uiElement.VerticalAlignment = VerticalAlignment.Stretch; }
public override void OnInitializeEditElement(TreeDataColumnBase dataColumn, TreeGridHeaderCell uiElement, object dataContext) { TreeGridColumn column = dataColumn.TreeGridColumn; //#if WPF // if (!TreeGrid.IsLoaded) // column = column.Clone() as TreeGridColumn; //#endif uiElement.TreeGrid = this.TreeGrid; uiElement.Column = dataColumn.TreeGridColumn; if (column != null) { if (column.HeaderText == null) { column.HeaderText = column.MappingName; } uiElement.SetValue(ContentControl.ContentProperty, column.HeaderText); //We need bind the HorizontalHeaderContentAlignment value if only column has HorizontalHeaderContentAlignment value if (column.ReadLocalValue(TreeGridColumn.HorizontalHeaderContentAlignmentProperty) != DependencyProperty.UnsetValue) { uiElement.SetValue(Control.HorizontalContentAlignmentProperty, column.HorizontalHeaderContentAlignment); } else { uiElement.ClearValue(Control.HorizontalContentAlignmentProperty); } uiElement.Update(); uiElement.DataContext = column; } }
protected override void InitializeCellStyle(TreeDataColumnBase treeDataColumn, object record) { var cell = treeDataColumn.ColumnElement; var column = treeDataColumn.TreeGridColumn; var cellRowColumnIndex = new RowColumnIndex(treeDataColumn.RowIndex, treeDataColumn.ColumnIndex); var control = cell as TreeGridHeaderCell; if (control != null && TreeGrid != null && column != null) { if (this.TreeGrid.AllowResizingColumns && this.TreeGrid.AllowResizingHiddenColumns) { var columnIndex = this.TreeGrid.ResolveToGridVisibleColumnIndex(cellRowColumnIndex.ColumnIndex); this.TreeGrid.ColumnResizingController.EnsureVSMOnColumnCollectionChanged(-1, columnIndex); } // UWP-4721 Reset the style while resuing a column with HeaderStyle for GridHeaderCellControl. if (!column.hasHeaderStyle && !TreeGrid.hasHeaderStyle) { if (control.ReadLocalValue(GridHeaderCellControl.StyleProperty) != DependencyProperty.UnsetValue) { control.ClearValue(GridHeaderCellControl.StyleProperty); } } else { Style style = null; if (column.hasHeaderStyle) { style = column.HeaderStyle; } else if (TreeGrid.hasHeaderStyle) { style = TreeGrid.HeaderStyle; } // WPF-35780 - When the Headerstyle is explicitly set null value for a column whether TreeGrid Headerstyle is enabled, // we need to clear the style for the column. if (style != null) { control.Style = style; } else { control.ClearValue(GridHeaderCellControl.StyleProperty); } } if (!column.hasHeaderTemplate && !TreeGrid.hasHeaderTemplate) { control.ClearValue(GridHeaderCellControl.ContentTemplateProperty); } else if (column.hasHeaderTemplate) { control.ContentTemplate = column.HeaderTemplate; } else if (TreeGrid.hasHeaderTemplate) { control.ContentTemplate = TreeGrid.HeaderTemplate; } } }
/// <summary> /// Called when [initialize display element]. /// </summary> /// <param name="dataColumn">TreeDataColumn Which holds TreeGridColumn, RowColumnIndex and TreeGridCell </param> /// RowColumnIndex - RowColumnIndex for the Renderer Element /// <param name="uiElement">Corresponding Renderer Element</param> /// TreeGridColumn - Column which is providing the information for Binding /// <param name="dataContext">The data context.</param> public override void OnInitializeDisplayElement(TreeDataColumnBase dataColumn, TextBlock uiElement, object dataContext) { base.OnInitializeDisplayElement(dataColumn, uiElement, dataContext); //Note: Padding cannot be binded for Display UI Element, since the padding will be irregular to match Edit/Display UI Elements //The Column will be refreshed via Dependency CallBack. uiElement.Padding = dataColumn.TreeGridColumn.padding; }
/// <summary> /// Updates the binding of the Cell UIElement for the specified column. /// Implement this method to update binding when the cell UIElement is reused during horizontal scrolling. /// </summary> /// <param name="dataColumn"> /// Specifies the corresponding column to update binding. /// </param> /// <param name="record"> /// The corresponding record to update binding. /// </param> /// <param name="isInEdit"> /// Indicates the whether the cell is editable or not. /// </param> protected internal override void OnUpdateBindingInfo(TreeDataColumnBase dataColumn, object record, bool isInEdit) { RowColumnIndex cellRowColumnIndex = new RowColumnIndex(dataColumn.RowIndex, dataColumn.ColumnIndex); FrameworkElement uiElement = dataColumn.ColumnElement; TreeGridColumn column = dataColumn.TreeGridColumn; FrameworkElement rendererElement = null; if (UseOnlyRendererElement) { rendererElement = uiElement as FrameworkElement; } else if (uiElement is TreeGridCell) { rendererElement = (uiElement as TreeGridCell).Content is FrameworkElement ? (uiElement as TreeGridCell).Content as FrameworkElement : uiElement; } if (this.SupportsRenderOptimization && !isInEdit) { if (!column.hasCellTemplate && !column.hasCellTemplateSelector) { OnUpdateDisplayBinding(dataColumn, (D)rendererElement, record); } else { OnUpdateTemplateBinding(dataColumn, (ContentControl)rendererElement, record); } } else { OnUpdateEditBinding(dataColumn, (E)rendererElement, record); } }
public override void OnInitializeEditElement(TreeDataColumnBase dataColumn, TreeGridRowHeaderCell uiElement, object dataContext) { RowColumnIndex rowColumnIndex = new RowColumnIndex(dataColumn.RowIndex, dataColumn.ColumnIndex); if (uiElement is TreeGridRowHeaderCell) { (uiElement as TreeGridRowHeaderCell).RowIndex = rowColumnIndex.RowIndex; } }
public override bool EndEdit(TreeDataColumnBase dc, object record, bool canResetBinding = false) { if (canResetBinding) { var CurrentCellUIElement = (Selector)CurrentCellRendererElement; CurrentCellUIElement.ClearValue(Selector.SelectedValueProperty); } return(base.EndEdit(dc, record, canResetBinding)); }
/// <summary> /// Ends the edit occurring on the cell. /// </summary> /// <param name="dc"> /// The corresponding datacolumn to complete the edit operation. /// </param> /// <param name="record"> /// The corresponding record to complete the edit operation. /// </param> /// <param name="canResetBinding"> /// Specifies whether the binding is reset or not. /// </param> /// <returns> /// Returns <b>true</b> if the edit ends on the cell ; otherwise, <b>false</b>. /// </returns> public override bool EndEdit(TreeDataColumnBase dc, object record, bool canResetBinding = false) { var cellRowColumnIndex = new RowColumnIndex(dc.RowIndex, dc.ColumnIndex); var cellElement = dc.ColumnElement; var column = dc.TreeGridColumn; if (!this.HasCurrentCellState) { return(false); } if (!this.IsInEditing) { return(false); } if (this.SupportsRenderOptimization) { #if WPF E uiElement = null; if (!UseOnlyRendererElement && cellElement is TreeGridCell) { uiElement = (E)((cellElement as TreeGridCell).Content is FrameworkElement ? (cellElement as TreeGridCell).Content as FrameworkElement : cellElement); } else { uiElement = cellElement as E; } uiElement.PreviewLostKeyboardFocus -= OnLostKeyboardFocus; #endif //this.IsFocused = false; this.SetFocus(false); var dataColumn = (cellElement as TreeGridCell).ColumnBase; OnEditingComplete(dataColumn, CurrentCellRendererElement); if (!UseOnlyRendererElement && cellElement == null) { throw new Exception("Cell Element will not be get null for any case"); } OnUnloadUIElements(dataColumn); OnPrepareUIElements(dataColumn, record, false); if (!column.hasCellTemplate && !column.hasCellTemplateSelector) { UpdateCurrentCellState((cellElement as TreeGridCell).Content as FrameworkElement, false); } else { UpdateCurrentCellState(cellElement as FrameworkElement, false); } } else { UpdateCurrentCellState(this.CurrentCellRendererElement, false); } return(!this.IsInEditing); }
protected override void OnEnteredEditMode(TreeDataColumnBase dataColumn, FrameworkElement currentRendererElement) { #if WPF if ((currentRendererElement as ComboBox).StaysOpenOnEdit && (currentRendererElement as ComboBox).IsEditable) #else if ((currentRendererElement as ComboBox).IsEditable) #endif { (currentRendererElement as ComboBox).IsDropDownOpen = true; } base.OnEnteredEditMode(dataColumn, currentRendererElement); }
protected override void InitializeCellStyle(TreeDataColumnBase dataColumn, object record) { var cell = dataColumn.ColumnElement; var cellRowColumnIndex = new RowColumnIndex(dataColumn.RowIndex, dataColumn.ColumnIndex); var element = cell as TreeGridRowHeaderCell; if (element != null) { element.RowIndex = cellRowColumnIndex.RowIndex; } base.InitializeCellStyle(dataColumn, record); }
public override bool EndEdit(TreeDataColumnBase dc, object record, bool canResetBinding = false) { if (canResetBinding) { var CurrentCellUIElement = (DateTimeEdit)CurrentCellRendererElement; #if UWP CurrentCellUIElement.ClearValue(DateTimeEdit.ValueProperty); #else CurrentCellUIElement.ClearValue(DateTimeEdit.DateTimeProperty); #endif } return(base.EndEdit(dc, record, canResetBinding)); }
/// <summary> /// Called when [initialize display element]. /// </summary> /// <param name="dataColumn">TreeDataColumn Which holds TreeGridColumn, RowColumnIndex and GridCell </param> /// RowColumnIndex - RowColumnIndex for the Renderer Element /// <param name="uiElement">Corresponding Renderer Element</param> /// GridColumn - Column which is providing the information for Binding /// <param name="dataContext">The data context.</param> public override void OnInitializeDisplayElement(TreeDataColumnBase dataColumn, ContentControl uiElement, object dataContext) { var column = dataColumn.TreeGridColumn; var gridcolumn = column as TreeGridComboBoxColumn; uiElement.SetBinding(ContentControl.ContentProperty, column.DisplayBinding); uiElement.SetValue(Control.HorizontalAlignmentProperty, TextAlignmentToHorizontalAlignment(gridcolumn.TextAlignment)); uiElement.SetValue(Control.VerticalAlignmentProperty, column.VerticalAlignment); if (gridcolumn.ItemTemplate != null) { uiElement.ContentTemplate = gridcolumn.ItemTemplate; } uiElement.Margin = gridcolumn.padding; }
/// <summary> /// Called when [initialize display element]. /// </summary> /// <param name="dataColumn">DataColumn which holds TreeGridColumn, RowColumnIndex and TreeGridCell </param> /// RowColumnIndex - RowColumnIndex for the Renderer Element /// <param name="uiElement">Corresponding Renderer Element</param> /// TreeGridColumn - Column which is providing the information for Binding /// <param name="dataContext">The data context.</param> public override void OnInitializeTemplateElement(TreeDataColumnBase dataColumn, ContentControl uiElement, object dataContext) { TreeGridColumn column = dataColumn.TreeGridColumn; if (column.hasCellTemplate || column.hasCellTemplateSelector) { base.OnInitializeTemplateElement(dataColumn, uiElement, dataContext); } else { InitializeDisplayTemplate(uiElement, column as TreeGridTemplateColumn, dataContext); OnUpdateTemplateBinding(dataColumn, uiElement, dataContext); } }
/// <summary> /// Raises the <see cref="Syncfusion.UI.Xaml.TreeGrid.SfTreeGrid.CurrentCellValueChanged"/> event. /// </summary> /// <param name="treeGrid"> /// The corresponding grid that contains the cell value changes . /// </param> /// <param name="dataColumn"> /// The data column Which holds TreeGridColumn, RowColumnIndex and TreeGridCell. /// </param> public void RaiseCurrentCellValueChangedEvent(SfTreeGrid treeGrid, TreeDataColumnBase dataColumn) { var e = new TreeGridCurrentCellValueChangedEventArgs(treeGrid) { RowColumnIndex = new RowColumnIndex() { RowIndex = dataColumn.RowIndex, ColumnIndex = dataColumn.ColumnIndex }, Record = currentCellRendererElement.DataContext, Column = dataColumn.TreeGridColumn }; TreeGrid.RaiseCurrentCellValueChangedEvent(e); }
/// <summary> /// Initialize the binding for TreeGridCell by Columns's CellTemplate and CellTemplateSelector. /// </summary> /// <param name="dataColumn">Specifies the dataColumn which contain TreeGridColumn, RowColumnIndex</param> /// <param name="uiElement">Specifies the display control to initialize binding</param> /// <param name="dataContext">Specifies the data context of the particular row</param> public override void OnInitializeTemplateElement(TreeDataColumnBase dataColumn, ContentControl uiElement, object dataContext) { TreeGridColumn column = dataColumn.TreeGridColumn; if (column.hasCellTemplate) { uiElement.ContentTemplate = column.CellTemplate; } else if (column.hasCellTemplateSelector) { uiElement.ContentTemplateSelector = column.CellTemplateSelector; } OnUpdateTemplateBinding(dataColumn, uiElement, dataContext); }
/// <summary> /// Called when [initialize edit element]. /// </summary> /// <param name="dataColumn">TreeDataColumn Which holds TreeGridColumn, RowColumnIndex and TreeGridCell </param> /// RowColumnIndex - RowColumnIndex for the Renderer Element /// <param name="uiElement">Corresponding Renderer Element</param> /// TreeGridColumn - Column which is providing the information for Binding /// <param name="dataContext">The data context.</param> public override void OnInitializeEditElement(TreeDataColumnBase dataColumn, DoubleTextBox uiElement, object dataContext) { base.OnInitializeEditElement(dataColumn, uiElement, dataContext); InitializeEditUIElement(uiElement, dataColumn.TreeGridColumn); #if UWP var wrapBind = new Binding { Path = new PropertyPath("TextWrapping"), Source = dataColumn.TreeGridColumn }; uiElement.SetBinding(TextBox.TextWrappingProperty, wrapBind); uiElement.ValueChangedMode = ValueChange.OnKeyFocus; #else uiElement.TextSelectionOnFocus = false; #endif BindingExpression = uiElement.GetBindingExpression(DoubleTextBox.ValueProperty); }
/// <summary> /// Called when [initialize edit element]. /// </summary> /// <param name="dataColumn">TreeDataColumn which holds TreeGridColumn, RowColumnIndex and TreeGridCell </param> /// RowColumnIndex - RowColumnIndex for the Renderer Element /// <param name="uiElement">Corresponding Renderer Element</param> /// TreeGridColumn - Column which is providing the information for Binding /// <param name="dataContext">The data context.</param> public override void OnInitializeEditElement(TreeDataColumnBase dataColumn, TextBox uiElement, object dataContext) { var column = dataColumn.TreeGridColumn; base.OnInitializeEditElement(dataColumn, uiElement, dataContext); var bind = column.ValueBinding.CreateEditBinding(column.GridValidationMode != GridValidationMode.None, column); uiElement.SetBinding(TextBox.TextProperty, bind); BindingExpression = uiElement.GetBindingExpression(TextBox.TextProperty); #if UWP var Bind = new Binding { Path = new PropertyPath("IsSpellCheckEnabled"), Mode = BindingMode.TwoWay, Source = column }; uiElement.SetBinding(TextBox.IsSpellCheckEnabledProperty, Bind); #endif }
public override void OnUpdateEditBinding(TreeDataColumnBase dataColumn, ContentControl uiElement, object dataContext) { TreeGridColumn column = dataColumn.TreeGridColumn; if (column.SetCellBoundValue) { var dataContextHelper = new TreeGridDataContextHelper { Record = dataContext, DataRow = dataColumn.DataRow }; dataContextHelper.SetValueBinding(column.ValueBinding, dataContext); uiElement.Content = dataContextHelper; } else { uiElement.SetBinding(ContentControl.ContentProperty, new Binding()); } }
public override void OnInitializeEditElement(TreeDataColumnBase dataColumn, HyperlinkButton uiElement, object dataContext) #endif { var column = dataColumn.TreeGridColumn; uiElement.SetValue(FrameworkElement.MarginProperty, column.Padding); uiElement.SetValue(Control.PaddingProperty, column.Padding); uiElement.SetValue(Control.VerticalAlignmentProperty, column.VerticalAlignment); var hyperLinkColumn = (TreeGridHyperlinkColumn)column; #if WPF // WPF-20330 - Reusing the content instead of create new hyperlink each time, to keep its stuffs like event, etc . Hyperlink content = null; var hyperlink = uiElement.Inlines.Cast <Hyperlink>().FirstOrDefault(); content = hyperlink ?? new Hyperlink(); content.FocusVisualStyle = null; uiElement.Inlines.Add(content); //WPF-24516 - To Navigate the hyperlink in the First Click by setting Foreground as null. uiElement.Foreground = null; var run = new Run(); run.SetBinding(Run.TextProperty, column.DisplayBinding); //Set Value Binding to NavigateUriProperty in Hyperlink control. content.SetBinding(Hyperlink.NavigateUriProperty, column.ValueBinding); content.Tag = new RowColumnIndex(dataColumn.RowIndex, dataColumn.ColumnIndex); content.Inlines.Clear(); content.Inlines.Add(run); if (hyperLinkColumn == null) { return; } #else var textBlock = new TextBlock(); uiElement.Content = textBlock; textBlock.SetBinding(TextBlock.TextProperty, column.ValueBinding); if (hyperLinkColumn == null) { return; } textBlock.SetValue(TextBlock.TextWrappingProperty, hyperLinkColumn.TextWrapping); #endif uiElement.SetValue(TextBlock.TextWrappingProperty, hyperLinkColumn.TextWrapping); uiElement.SetValue(Control.HorizontalAlignmentProperty, hyperLinkColumn.HorizontalAlignment); }
/// <summary> /// Called when [initialize edit element]. /// </summary> /// <param name="dataColumn">TreeDataColumn Which holds GridColumn, RowColumnIndex and GridCell </param> /// RowColumnIndex - RowColumnIndex for the Renderer Element /// <param name="uiElement">Corresponding Renderer Element</param> /// TreeGridColumn - Column which is providing the information for Binding /// <param name="dataContext">The data context.</param> public override void OnInitializeEditElement(TreeDataColumnBase dataColumn, DateTimeEdit uiElement, object dataContext) { var column = dataColumn.TreeGridColumn; InitializeEditUIElement(uiElement, column); BindingExpression = uiElement.GetBindingExpression(DateTimeEdit.DateTimeProperty); #if !UWP base.OnInitializeEditElement(dataColumn, uiElement, dataContext); #else var textPadding = new Binding { Path = new PropertyPath("Padding"), Mode = BindingMode.TwoWay, Source = column }; uiElement.SetBinding(Control.PaddingProperty, textPadding); uiElement.VerticalAlignment = VerticalAlignment.Stretch; uiElement.HorizontalAlignment = HorizontalAlignment.Stretch; #endif uiElement.HorizontalContentAlignment = TextAlignmentToHorizontalAlignment(column.TextAlignment); }
public override bool EndEdit(TreeDataColumnBase dc, object record, bool canResetBinding = false) { if (canResetBinding) { var CurrentCellUIElement = (CheckBox)CurrentCellRendererElement; CurrentCellUIElement.ClearValue(CheckBox.IsCheckedProperty); } // WPF-25028 Updates the current binding target value to the binding source property in TwoWay or OneWayToSource bindings. if (BindingExpression != null #if WPF && BindingExpression.Status != BindingStatus.Detached #endif ) { BindingExpression.UpdateSource(); } return(base.EndEdit(dc, record, canResetBinding)); }
/// <summary> /// Called when [initialize edit element]. /// </summary> /// <param name="dataColumn">DataColumn Which holds TreeGridColumn, RowColumnIndex and TreeGridCell </param> /// RowColumnIndex - RowColumnIndex for the Renderer Element /// <param name="uiElement">Corresponding Renderer Element</param> /// TreeGridColumn - Column which is providing the information for Binding /// <param name="dataContext">The data context.</param> public override void OnInitializeEditElement(TreeDataColumnBase dataColumn, ComboBox uiElement, object dataContext) { var column = dataColumn.TreeGridColumn; InitializeEditBinding(uiElement, column); var textAlignment = new Binding { Path = new PropertyPath("TextAlignment"), Mode = BindingMode.OneWay, Source = column, Converter = new TextAlignmentToHorizontalAlignmentConverter() }; uiElement.SetBinding(Control.HorizontalContentAlignmentProperty, textAlignment); var verticalAlignment = new Binding { Path = new PropertyPath("VerticalAlignment"), Mode = BindingMode.TwoWay, Source = column }; uiElement.SetBinding(Control.VerticalContentAlignmentProperty, verticalAlignment); #if UWP uiElement.HorizontalAlignment = HorizontalAlignment.Stretch; uiElement.VerticalAlignment = VerticalAlignment.Stretch; #endif }
/// <summary> /// Invoked when the cell is scrolled out of view or unloaded from the view. /// <see cref="Syncfusion.UI.Xaml.TreeGrid.Cells.TreeGridVirtualizingCellRendererBase < D,E >"/> overrides this method and either removes the cell renderer visuals from the parent /// or hide them and reuse it later in same element depending on whether <see cref="Syncfusion.UI.Xaml.TreeGrid.Cells.TreeGridVirtualizingCellRendererBase< D,E >.AllowRecycle"/> was set. /// </summary> /// <param name="dataColumn"> /// Specifies the column to unload the cell UIElement. /// </param> protected override void OnUnloadUIElements(TreeDataColumnBase dataColumn) { var cellRowColumnIndex = new RowColumnIndex(dataColumn.RowIndex, dataColumn.ColumnIndex); var uiElements = dataColumn.ColumnElement; if (this.HasCurrentCellState && this.IsInEditing && this.CurrentCellIndex == cellRowColumnIndex) { UnloadEditUIElement(uiElements, dataColumn); } else { if (SupportsRenderOptimization) { UnloadDisplayUIElement(uiElements, dataColumn); } else { UnloadEditUIElement(uiElements, dataColumn); } } }
/// <summary> /// Initializes the cell style. /// </summary> /// <param name="record">The record.</param> /// <param name="dataColumn">DataColumn which holds TreeGridColumn, RowColumnIndex and TreeGridCell </param> /// RowColumnIndex - RowColumnIndex for the Renderer Element /// TreeGridColumn - Column which is providing the information for Binding protected override void InitializeCellStyle(TreeDataColumnBase dataColumn, object record) { var cell = dataColumn.ColumnElement; base.InitializeCellStyle(dataColumn, record); var cellRowColumnIndex = new RowColumnIndex(dataColumn.RowIndex, dataColumn.ColumnIndex); var uiElement = (cell as TreeGridCell).Content as ContentControl; var gridColumn = dataColumn.TreeGridColumn as TreeGridTemplateColumn; if (uiElement != null && gridColumn != null) { if (HasCurrentCellState && CurrentCellIndex == cellRowColumnIndex && IsInEditing) { InitializeEditTemplate(uiElement, gridColumn, record); } else if (gridColumn.hasCellTemplate || gridColumn.hasCellTemplateSelector || (TreeGrid != null && TreeGrid.hasCellTemplateSelector)) { OnInitializeTemplateElement(dataColumn, uiElement, record); } } }
/// <summary> /// Initialize the binding for display element of corresponding column. /// </summary> /// <param name="dataColumn">Specifies the dataColumn which contain TreeGridColumn, RowColumnIndex</param> /// <param name="uiElement">Specifies the display control to initialize binding</param> /// <param name="dataContext">Specifies the data context of the particular row</param> public override void OnInitializeDisplayElement(TreeDataColumnBase dataColumn, D uiElement, object dataContext) { TreeGridColumn column = dataColumn.TreeGridColumn; uiElement.SetBinding(TextBlock.TextProperty, column.DisplayBinding); uiElement.SetValue(TextBlock.TextAlignmentProperty, column.textAlignment); uiElement.SetValue(Control.VerticalAlignmentProperty, column.verticalAlignment); var textColumnBase = column as TreeGridTextColumnBase; if (textColumnBase == null) { return; } uiElement.SetValue(TextBlock.TextTrimmingProperty, textColumnBase.textTrimming); uiElement.SetValue(TextBlock.TextWrappingProperty, textColumnBase.textWrapping); #if WPF uiElement.SetValue(TextBlock.TextDecorationsProperty, textColumnBase.textDecoration); #endif }
/// <summary> /// To unload edit elements /// </summary> /// <param name="uiElements"></param> /// <param name="column">Need column to check if column has HeaderTemplate</param> private void UnloadEditUIElement(FrameworkElement uiElements, TreeDataColumnBase column) { E uiElement = null; if (!UseOnlyRendererElement && uiElements is TreeGridCell) { uiElement = (E)((uiElements as TreeGridCell).Content is FrameworkElement ? (uiElements as TreeGridCell).Content as FrameworkElement : uiElements); } else { uiElement = uiElements as E; column.ColumnElement = null; } if (uiElement != null) { UnwireEditUIElement(uiElement); if (AllowRecycle && !(uiElement is TreeGridCell)) { EditRecycleBin.Enqueue(this, uiElement); } if (!UseOnlyRendererElement && uiElements is TreeGridCell) { ResetGridCell((ContentControl)uiElements); } else if (uiElement.Parent is Panel) { if (column.TreeGridColumn != null && column.TreeGridColumn.hasHeaderTemplate || TreeGrid.hasHeaderTemplate) { ResetGridCell((ContentControl)uiElements); } (uiElement.Parent as Panel).Children.Remove(uiElement); } } }
/// <summary> /// Called when [initialize edit element]. /// </summary> /// <param name="dataColumn">TreeDataColumn which holds TreeGridColumn, RowColumnIndex and TreeGridCell </param> /// RowColumnIndex - RowColumnIndex for the Renderer Element /// <param name="uiElement">Corresponding Renderer Element</param> /// TreeGridColumn - Column which is providing the information for Binding /// <param name="dataContext">The data context.</param> public override void OnInitializeEditElement(TreeDataColumnBase dataColumn, ContentControl uiElement, object dataContext) { InitializeEditTemplate(uiElement, (TreeGridTemplateColumn)dataColumn.TreeGridColumn, dataContext); OnUpdateEditBinding(dataColumn, uiElement, dataContext); CanFocus = true; }
/// <summary> /// Method overridden to avoid binding for a content cntrol when cell template is not defined. /// </summary> /// <param name="dataColumn"></param> /// <param name="uiElement"></param> /// <param name="dataContext"></param> public override void OnInitializeDisplayElement(TreeDataColumnBase dataColumn, ContentControl uiElement, object dataContext) { }