How to expose commands for a Hyperlink button in Silverlight Telerik Radgrid
To give you background, i am using Silverlight + MVVM and PRISM.
I have some Master data to show in grid and have the first column as hyperlink to the detail data. I am trying to expose some command for a Hyperlink button, but it doesnt seem t开发者_StackOverflow社区o work fine.
Here's my XAML ->
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Header="Detail ID">
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<HyperlinkButton Content="{Binding DetailID}"
Command="{Binding SelectGridItemCommand}"
CommandParameters={Binding}
/>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
</telerik:GridViewDataColumn>
... [other columns]
</<telerik:RadGridView.Columns>
Basically, I want to do some processing on the text that is present on the Column name and navigate to the detail page.
Can someone help me here..
I found what I was doing wrong. I had bound an Model object in the viewModel to the Grid and when I wrote the binding command in ViewModel, i dint specify that it needs to change the data context to my viewmodel.
Anyways I eventually wrote an delegate and exposed an event in the Model class and subscribed to that event in the ViewModel where I handled it with my custom EventHandlerArgs.
With Caliburn Micro the binding is seamless, if you name control, let's say 'SelectDetail', the adjacent ViewModel's method should be named SelectDetail as well. Evenmore, if you create a boolean property named as CanSelectDetail there will be an 'automagic' binding to IsEnabled Hyperlikn's property
精彩评论