I have a list of 'Setting' objects in a ViewModel a RadPropertyGrid is bound to. I use OnLoaded event to populate PropertyDefinitions of the RadPropertyGrid with 'Setting' items from the list by creating a PropertyDefinition for each item. DisplayName and Description for each PropertyDefinition created from a 'Setting' object are set correctly but I cannot set the Binding to display the actual value to be edited. Here is my code:
foreach (var setting in vm.Settings)
{
Binding myBinding = new Binding();
myBinding.Source = setting;
myBinding.Path = new PropertyPath("SomeProperty");
var pd = new PropertyDefinition();
pd.Binding = myBinding;
pd.DisplayName = setting.Name;
pd.Description = setting.Description;
ServerSettingsPropertyGrid.PropertyDefinitions.Add(pd);
}
What am I doing wrong and how to properly set PropertyDefinition binding in code?
foreach (var setting in vm.Settings)
{
Binding myBinding = new Binding();
myBinding.Source = setting;
myBinding.Path = new PropertyPath("SomeProperty");
var pd = new PropertyDefinition();
pd.Binding = myBinding;
pd.DisplayName = setting.Name;
pd.Description = setting.Description;
ServerSettingsPropertyGrid.PropertyDefinitions.Add(pd);
}
What am I doing wrong and how to properly set PropertyDefinition binding in code?