Hi All,
I am using xamgrid(datagrid) and I have 8 columns in that I need one column header text binding at runtime because of some business logic the column header text should be change. So I have created one property in my viewmodel and trying to bind it to xamgrid column header text but it is not binding.
Can any one help me how to bind my viewmodel property to xamgrid column header text or any sample with the same scenario.
Thanks in advance
HI,
Please let me know if you need further assistance regarding this issue.
Sincerely, Matt Developer Support Engineer
The TextColumn is not a FrameworkElement. You cannot use datacontext binding. the only way to bind the HeaderText is to use a staticresource.
You could declare your ViewModel as a resource in your APP.xaml,
Then set your DataContext to this resource.
Hi Matt,
Thanks for your reply. I don't see much difference between your previous sample code and latest code. Here is how my exact behaviour of the control
1. I have a xamgrid in silverlight page (sampleview.xaml)
2. I am defined Datacontext for my page in sampleview.xmal.cs as DataContext = new SampleViewModel();
3. I am not defining my view model with in the xaml as static resource.
Please provide me your inputs on how can I bind my datagrid header text with out static reource or please correct me if my understanding is incorrect
Thanks in advance.
I modified the sample to use a usercontrol. I moved the viewmodel into the app.xaml.
Please review my sample sample.
Thanks for your input,
Here I am using my viewmodel as Datacontext for usercontrol, I am not including it in User control resources. Can you please provide me your inputs on how can I use my Datacontext as Source for Grid Header text.