Reputation: 47
I want to click the whole row in my gridview and it will show me a dialog box. This dialog box contains values on my grid itself. Here is my sample xaml code..
<telerik:GridViewDataColumn Header="First Name" Width="*" DataMemberBinding="{Binding FirstName}" />
<telerik:GridViewDataColumn Header="Last Name" Width="*" DataMemberBinding="{Binding LastName}" />
<telerik:GridViewDataColumn Header="Middle Name" Width="*" DataMemberBinding="{Binding MiddleName}" />
<telerik:GridViewDataColumn Header="Registration Day" Width="*" DataMemberBinding="{Binding RegistrationDay, StringFormat={}{0:dd/MM/yyyy}}" />
<telerik:GridViewDynamicHyperlinkColumn Header="Email" Width="*" DataMemberBinding="{Binding Email}" />
<telerik:GridViewDataColumn Header="Password" Width="*" DataMemberBinding="{Binding Access}" />
those values are also the values in my dialog box. I just want to make double click with the row, instead of clicking the edit button that I implement.. Hope you can help me..
Upvotes: 1
Views: 4147
Reputation: 5763
If you're using MVVM, you would probably prefer to attach an ICommand, which will be passed the DataContext of the row that has been clicked on, as a parameter.
Upvotes: 0
Reputation: 1372
two ways:
set gridview's IsReadOnly = true
and than set gridview's MouseDoubleClick Event:
private void dg1_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
Student s = dg1.SelectedItem as Student;
if (s != null)
{
MessageBox.Show(s.Name + " " + s.Age);
}
}
set gridview's PreviewMouseDoubleClick Event:
private void dg1_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
{
Student s = dg1.SelectedItem as Student;
if (s != null)
{
MessageBox.Show(s.Name + " " + s.Age);
}
e.Handled = true;
}
Upvotes: 2