我正在使用Caliburn.Micro MVVM框架,还希望使用Devexpress GridControl。当我为WPF GridView编写此代码时,一切正常:
<DataGrid HorizontalAlignment="Left"
ItemsSource="{Binding Students}"
Height="474" VerticalAlignment="Top"
Width="654" Margin="10,246,0,0">
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Setter Property="cal:Message.Attach"
Value="[MouseDoubleClick]=[Action RowSelect($dataContext)]"/>
</Style>
</DataGrid.RowStyle>
</DataGrid>
但是,当我对Devexpress GridControl进行相同操作时:
<dxg:GridControl AutoGenerateColumns="AddNew"
ItemsSource="{Binding Students}"
EnableSmartColumnsGeneration="True"
HorizontalAlignment="Left"
Margin="688,246,0,0"
VerticalAlignment="Top"
Height="474" Width="1072">
<dxg:GridControl.View>
<dxg:TableView AllowPerPixelScrolling="True"
ShowTotalSummary="True">
<dxg:TableView.RowStyle>
<Style TargetType="dxg:RowControl">
<Setter Property="cal:Message.Attach"
Value="[MouseDoubleClick]=[Action RowSelect($dataContext)]"/>
</Style>
</dxg:TableView.RowStyle>
</dxg:TableView>
</dxg:GridControl.View>
</dxg:GridControl>
在我的RowSelect方法中,学生参数为空。
public void RowSelect(Student student)
{
MessageBox.Show(student.StudentCode + " " + student.StudentName);
}
如何更改此代码以使其正常工作?