<
telerik:RadGridView
x:Name
=
"Navigation"
AutoGenerateColumns
=
"False"
ItemsSource
=
"{StaticResource data}"
>
"data" is an ObservableCollection and I was expecting the grid to update, when the collection gets updated. Data already in the list after initialisation is shown. I guessed this does not work, as its a StaticResource, but with DynamicResource it also does not work.
However if i use c# code it works:
this.Navigation.ItemsSource = this.data;
Now its obvious to me I am doing something wrong with the ItemsSource in xaml, but I just have no clue what I should be doing...
4 Answers, 1 is accepted
I suppose that this setup will not work with any ItemsControl, but that's another story.
RadGridView definitely works with an ObservableCollection<T>. If it did not it would be totally useless. I am not really sure why you want to place the data as a static or dynamic resource, but that is not the best way in my opinion.
I have attached a sample project that shows how you should bind to a property residing on your view model.
To learn more about Data Binding, please read this.
I hope this helps.
Ross
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

is there no equivalent in xaml for the code I write in c#?
this.Navigation.ItemsSource = this.data;
I assumed i could set the ItemsSource in xaml in a similar way, as I can reference the data object. I am not too fond of microsoft documentation, but I will try to get through it ;)
I am not stunned at all.
Please, replace RadGridView with any other items control such as a stock ListBox or the stock DataGrid and tell me what happens. Do they work? Does the problem stem from RadGridView or from something else?
I understand that you are not fond of reading documentation, but if you take your time and read the things explained in the link I have provided you would not be asking these questions. You can't learn WPF by not reading about WPF. Trying every possible combination until something finally works is not the correct way to learn a new technology.
In XAML you use Bindings, you can't set things directly like that. There are many different bindings -- binding to a resource, binding to a property on the data context, binding to a property on another element (ElementName binding), TemplateBinding when you are inside a control template and so on.
But WPF Bindings are not a Telerik-related topic. Telerik forums are for Telerik product-related discussions.
Please, read the link that I have provided in order to learn how WPF works and in case you have other general WPF questions, my suggestion would be to please use the appropriate Microsoft forums.
If you have questions that are particularly related to Telerik controls we would be more than glad to answer them here. That's the purpose of these forums.
I hope this helps.
All the best,
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
