Now I try to bind the selected item of the GridView to the PropertyGrid also via code and not XAML.
I tried something like this:
Binding propGridBinding = new Binding("SelectedItem");
propGridBinding.ElementName = "myTreeListView"; // assuming this is the name of the GridView
propertyGrid.Item = propGridBinding;
But when I try to run this code I get an error message like this:
An unhandled exception of type 'System.NotSupportedException' occurred in System.dll
Additional information: 'CultureInfoIetfLanguageTagConverter' is unable to convert '(null)' to 'System.String'.
I even get the same type of error if I just try to bind the PropertyGrid to a visual element to be able to view and edit its properties.
I must be missing something.
Any help is very much appreciated.
Thanks,
Markus
6 Answers, 1 is accepted
You can set PropertyGrid's Item to be the SelectedItem of RadGridView in its SelectionChanged event. Please check the following code snippet for a reference:
RadPropertyGrid myPropertyGrid;
RadGridView myGridView;
public MainWindow()
{
InitializeComponent();
myGridView = new RadGridView();
myGridView.ItemsSource = Club.GetClubs();
myGridView.IsSynchronizedWithCurrentItem = true;
myGridView.SelectionChanged += myGridView_SelectionChanged;
myPropertyGrid = new RadPropertyGrid();
myPropertyGrid.Item = myGridView.SelectedItem;
}
void myGridView_SelectionChanged(object sender, SelectionChangeEventArgs e)
{
myPropertyGrid.Item = myGridView.SelectedItem;
}
I hope this helps.
Regards,
Yoan
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Just a quick follow-up - you can bind PropertyGrid's Item to GridView's SelectedItem in code-behind like so:
Binding binding = new Binding("SelectedItem") { ElementName = "myGridView" };
this.myPropertyGrid.SetBinding(RadPropertyGrid.ItemProperty, binding);
Regards,
Yoan
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

thanks for your answers. I'll give them a try soon and let you know how it works.
Markus
Please give it a try and let me know if you need further assistance on this.
Regards,
Yoan
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Hi Yoan,
I just have the same issue , I am generating rad grid view dynamically and want to set GridView's SelectedItem as my SelectedCustomer Property so I just tried
Binding binding = new Binding("SelectedItem") { ElementName = "radGridView" };
radGridView.SetBinding(RadPropertyGrid.ItemProperty, binding);
from modelview( I m nothing doing in .xaml file every thing I have to code from viewmodel)
And tried to get value inside
public DynamicEntity SelectedCustomer
{
get { return _selectedCustomer; }
set { _selectedCustomer = value; OnPropertyChanged("SelectedCustomer"); } //HERE I JUST SET BREAK POINT ON SELECTION OF GRID VIEW ROW BUT NOTHING IS CHANGE.
}
Then I just tried radGridView.SelectionChanged += new EventHandler<SelectionChangeEventArgs>(myGridView_SelectionChanged); it works fine but as in mvvm pattern , it's better to not bind any events with mvvm so can you tell how to resolve it , we are still trying telerik control and we are on poc base.....
I am sending you a sample project which demonstrates how to achieve the desired behavior. Basically, I am binding GridView's SelectedItem property to a SelectedItem property of my ViewModel, then the PropertyGrid's Item property is bound to ViewModel's SelectedItem property and everything works as expected.
I hope this helps.
Regards,
Yoan
Progress Telerik