Example #1
0
        /// <summary>
        /// 获取DataGridColumn BindingPath属性
        /// </summary>
        /// <param name="datagridcolumn"></param>
        /// <returns>BindingPath属性</returns>
        private static string GetBindingPath(DataGridColumn datagridcolumn)
        {
            string r = string.Empty;

            try
            {
                System.Windows.Controls.DataGridBoundColumn column = (System.Windows.Controls.DataGridBoundColumn)datagridcolumn;
                System.Windows.Data.Binding matchBinding           = (System.Windows.Data.Binding)column.Binding;
                r = matchBinding.Path.Path;
            }
            catch (Exception ex)
            {
                // TODO 如何获取 System.Windows.Controls.DataGridTemplateColumn 的 Binding 属性
                if (ex.Message.Contains("System.Windows.Controls.DataGridTemplateColumn") &&
                    ex.Message.Contains("System.Windows.Controls.DataGridBoundColumn"))
                {
                    r = datagridcolumn.SortMemberPath; // 暂时先取 SortMemberPath
                }
                else
                {
                    throw ex;
                }
            }
            return(r);
        }
 internal void OnColumnBindingChanged(DataGridBoundColumn column)
 {
     // Update Binding in Displayed rows by regenerating the affected elements
     if (_rowsPresenter != null)
     {
         foreach (DataGridRow row in GetAllRows())
         {
             PopulateCellContent(false /*isCellEdited*/, column, row, row.Cells[column.Index]);
         }
     }
 }
        // Token: 0x060046CD RID: 18125 RVA: 0x001413D0 File Offset: 0x0013F5D0
        private static object OnCoerceSortMemberPath(DependencyObject d, object baseValue)
        {
            DataGridBoundColumn dataGridBoundColumn = (DataGridBoundColumn)d;
            string text = (string)baseValue;

            if (string.IsNullOrEmpty(text))
            {
                string pathFromBinding = DataGridHelper.GetPathFromBinding(dataGridBoundColumn.Binding as Binding);
                if (!string.IsNullOrEmpty(pathFromBinding))
                {
                    text = pathFromBinding;
                }
            }
            return(text);
        }
        internal string GetSortPropertyName()
        {
            string result = this.SortMemberPath;

            if (String.IsNullOrEmpty(result))
            {
                DataGridBoundColumn boundColumn = this as DataGridBoundColumn;

                if (boundColumn != null && boundColumn.Binding != null && boundColumn.Binding.Path != null)
                {
                    result = boundColumn.Binding.Path.Path;
                }
            }

            return(result);
        }
 internal void OnColumnElementStyleChanged(DataGridBoundColumn column)
 {
     // Update Element Style in Displayed rows
     foreach (DataGridRow row in GetAllRows())
     {
         FrameworkElement element = column.GetCellContent(row);
         if (element != null)
         {
             element.SetStyleWithType(column.ElementStyle);
         }
     }
     InvalidateRowHeightEstimate();
 }
Example #6
0
 internal void OnColumnElementStyleChanged(DataGridBoundColumn column)
 {
     // Update Element Style in Displayed rows
     if (_rowsPresenter != null)
     {
         foreach (DataGridRow row in _rowsPresenter.Children)
         {
             FrameworkElement element = column.GetCellContent(row);
             // 
             if (element != null && element.Style == null)
             {
                 element.Style = column.ElementStyle;
             }
         }
         InvalidateRowHeightEstimate();
     }
 }
Example #7
0
 internal void OnColumnBindingChanged(DataGridBoundColumn column)
 {
     // Update Binding in Displayed rows by regenerating the affected elements
     if (_rowsPresenter != null)
     {
         foreach (DataGridRow row in _rowsPresenter.Children)
         {
             PopulateCellContent(true /* forceTemplating */, false, column, row, row.Cells[column.Index]);
         }
     }
 }