Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
430
XamDataGrid Unbound field BindingPath
posted

Hi,

I am using WPF controls version 12.2 XamDataGrid in my application. I am trying to create some Unbound columns during GridInitialize method. I am also a view model which returns me the data into a data table that I use to bind the columns in XamDataGrid.

The issue I am running into is the columns are dynamic and it gets the label from database which happens to have comma in the field name/label. Here is how I am setting the properties of unbound field.

 

       

public static UnboundField GetUnboundField(string name, string label, bool isVisible, bool isAllowEdit)

        {  


var field = new UnboundField()

             {

                 Name = name,

                 Label = label,

                 Visibility = isVisible ==true ? Visibility.Visible : Visibility.Collapsed,

                 BindingPath =new PropertyPath(string.Format("Data[{0}]", name)),

                 BindingMode =BindingMode.TwoWay,

                 Width =FieldLength.Auto,

             };

            field.Settings.AllowEdit = isAllowEdit;

         return field;

        }

As you notice, when I am passing the name which has a comma, the value is not being bound even though my data table has value.

For example: Column Name from data table = "CY Salary,Incentive and Award"

BindingPath is coming as Data[CY Salary,Incentive and Award]  --> does not bind the value to grid. If I remove the comma, I see the value in xamDataGrid.

I tried few things such as using escape character, enclosing the label in square brackets etc., but no luck.

 

Any help would be appreciated.

 

Thanks in advance.

Parvez