Hi,
We are using XAMGrid and we are going to bind header Text dynamically. Our requirement is that As we select the row as per row selection the header text will be changed. For that we make bind Header text in ViewModel. But Header Text are not showing in UI View.
Please help us for updating Header Text in XAMGrid.
Thanks
I looked into this and I don't want to instantiate the view model again with the default constructor as the property already has the value I'm looking for..
Unfortunately loading value from the resource file or static resource will not work as the view is dynamic and created via data template.
Hello,
The Columns(i.e. TextColumn, ComboBoxColumn, etc) in XamGrid are not visual elements(not exist within the visual tree) and since they don't derive from the FrameworkElement class they don't expose DataContext property. In order to bind the Columns's HeaderText to property from your view model, you will need to use the model as a Source or static resource in the Binding. You can download 'BindingColumnHeaderText.zip' project from Rob's post and test this approach.
Also you can read the 'Binding to Properties of non-FrameworkElements' blog post from our web site, for additional details about 'Binding to StaticResource' and 'Binding to a Data Context Proxy' approaches.
Let me know if you have any questions.
Sincerely,ZhivkoAssociate Software Developer
Is there a way to accomplish this from XAML accessing a property from viewmodel, I do have a dynamic grid that will have different column header value based on a property, so the static resource will not suffice for me, I can't get into the binding from column header so is there a solution for that situation?
Thanks!
SM
Hi piyu,
I added your XAML to a test project and as long as the view model objects existed the binding worked and I can see the "Param2" text in the column header. I'm not sure why it doesn't work for you. Compare your setup to my sample and see what is different.