5 Answers, 1 is accepted
0
Hello Richa,
All the best,
Maya
the Telerik team
You may handle the Click event of the button like follows:
private void Button1_Click(object sender, RoutedEventArgs e)
{
foreach(Club club in this.clubsGrid.SelectedItems)
{
var row = this.clubsGrid.ItemContainerGenerator.ContainerFromItem(club) as GridViewRow;
row.DetailsVisibility = Visibility.Visible;
}
}
Maya
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0

Richa
Top achievements
Rank 1
answered on 02 May 2011, 12:25 PM
Thanks, but i want to implement this using MVVM pattern.
Could you please let me know how will i get the selected row in the grid in my viewmodel?
Could you please let me know how will i get the selected row in the grid in my viewmodel?
0
Hello Richa,
However, the corresponding row and the row details are visual elements and will be breaking the concept of MVVM to work with the visual elements in your ViewModel.
Kind regards,
Maya
the Telerik team
You may get the SelectedItem of the RadGridView by binding it to a corresponding property in your ViewModel:
MainWindow.xaml
<
telerik:RadGridView
Name
=
"clubsGrid"
ItemsSource
=
"{Binding Clubs}"
AutoGenerateColumns
=
"False"
SelectedItem
=
"{Binding SelectedItem}"
>
MyViewModel.cs:
private object selectedItem;
public object SelectedItem
{
get { return this.selectedItem; }
set
{
if (value != this.selectedItem)
{
this.selectedItem = value;
this.OnPropertyChanged("SelectedItem");
}
}
}
However, the corresponding row and the row details are visual elements and will be breaking the concept of MVVM to work with the visual elements in your ViewModel.
Kind regards,
Maya
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0

Richa
Top achievements
Rank 1
answered on 02 May 2011, 01:02 PM
For showing the row details on a button click i need the reference of the grid in the viewmodel.
Can you please tell how will i get the reference of the grid in viewmodel?
Can you please tell how will i get the reference of the grid in viewmodel?
0
Hi Richa,
Maya
the Telerik team
As mentioned previously getting access of the visual elements and working with them in your ViewModel contradicts to the concept of Model-View-ViewModel design pattern. May you share a bit more details why handling the Click event of a button is not appropriate for your scenario ?
Maya
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items