Search code examples
c#wpfxceedxceed-datagrid

Rebinding a Xceed DataGrid column to accept special characters


I am trying to use an Xceed WPF DataGrid to display DataTable objects. The DataTables just so happens to have columns that utilize special characters such as "/". This led the Xceed DataGrid to run into the same problem as seen in this previous question.

I have tried to find Xceed analogies for the solution provided, but I am not sure how to use Xceed's DataGridBindingInfo class (which I believe governs the binding) to accomplish what I want. Is it even possible to changing the binding in this way with Xceed?


Solution

  • After using breakpoints to examine the state of the columns, I have discovered that auto generated columns in Xceed do not use the DataGridBindingInfo property as I originally thought. Instead it uses the depreciated DisplayMemberBinding property. I was able to solve my problem by modifying this property as shown below.

    foreach (var c in grid.Columns)
            {
                var column = c as Xceed.Wpf.DataGrid.Column;
                column.DisplayMemberBinding = new System.Windows.Data.Binding("[" + column.FieldName + "]");
            }