Beispiel #1
0
        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());
            }
        }
Beispiel #2
0
        /// <summary>
        /// Updates the tool tip for GridCell.
        /// </summary>
        /// <param name="dataColumn">Which holds GridColumn, Row Column Index and GridCell</param>
        public override void UpdateToolTip(TreeDataColumnBase dataColumn)
        {
            var uiElement = dataColumn.ColumnElement;
            var column    = dataColumn.TreeGridColumn;

            if (dataColumn.IsEditing || column == null || !column.ShowToolTip)
            {
                uiElement.ClearValue(ToolTipService.ToolTipProperty);
                return;
            }
            object dataContext = dataColumn.ColumnElement.DataContext;

            var     obj = ToolTipService.GetToolTip(uiElement);
            ToolTip tooltip;

            if (obj is ToolTip)
            {
                tooltip = obj as ToolTip;
            }
            else
            {
                tooltip = new ToolTip();
            }
            if (column.hasToolTipTemplate || column.hasToolTipTemplateSelector)
            {
                if (column.SetCellBoundToolTip)
                {
                    var dataContextHelper = new TreeGridDataContextHelper {
                        Record = dataContext
                    };
                    dataContextHelper.SetValueBinding(column.DisplayBinding, dataContext);
                    tooltip.Content = dataContextHelper;
                }
                else
                {
                    tooltip.Content = dataContext;
                }

                if (column.hasToolTipTemplate)
                {
                    tooltip.ContentTemplate = column.ToolTipTemplate;
                }
                else if (column.hasToolTipTemplateSelector)
                {
                    tooltip.ContentTemplateSelector = column.ToolTipTemplateSelector;
                }
            }
            else
            {
                var provider = column.TreeGrid.View.GetPropertyAccessProvider();
                if (provider != null)
                {
                    var displaytext = Convert.ToString(provider.GetFormattedValue(dataColumn.ColumnElement.DataContext, column.MappingName));
                    tooltip.Content = displaytext;
                    if (string.IsNullOrEmpty(displaytext))
                    {
                        tooltip.IsEnabled = false;
                    }
                }
            }
            //Specifies to raise tooltip opening event for the corresponding cell
            if (dataColumn.RaiseCellToolTipOpening(tooltip))
            {
                ToolTipService.SetToolTip(uiElement, tooltip);
            }
            else
            {
                uiElement.ClearValue(ToolTipService.ToolTipProperty);
            }
        }