我想点击gridview中的整行,它会显示一个对话框。此对话框包含网格本身的值。这是我的示例xaml代码..
<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}" />
这些值也是我对话框中的值。我只想双击该行,而不是单击我实现的编辑按钮。希望你能帮助我..
答案 0 :(得分:1)
两种方式:
设置gridview&#39; IsReadOnly = true
,然后设置gridview的MouseDoubleClick事件:
private void dg1_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
Student s = dg1.SelectedItem as Student;
if (s != null)
{
MessageBox.Show(s.Name + " " + s.Age);
}
}
设置gridview的PreviewMouseDoubleClick事件:
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;
}
答案 1 :(得分:0)
如果你正在使用MVVM,你可能更喜欢附加一个ICommand,它将作为参数传递给已被点击的行的DataContext。