赞
踩
我有一个ListView列表,我要实现双击某一行展开详细页,前台代码如下:其中MouseDoubleClick="myplaneLV_MouseDoubleClick"是双击事件,myplaneLV_MouseDoubleClick对应后台代码。
<ListView Margin="0,30,0,0" x:Name="myplaneLV" ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollBarVisibility="Hidden" MouseDoubleClick="myplaneLV_MouseDoubleClick"> <ListView.Resources> <!-- <Style TargetType="GridViewColumnHeader"> <Setter Property="Visibility" Value="Collapsed"></Setter> </Style>--> </ListView.Resources> <ListView.View> <GridView> <GridViewColumn Header="选择"> <GridViewColumn.CellTemplate> <DataTemplate> <CheckBox Content="" Click="CheckBox_Click" Tag="{Binding rowid}"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn Header="计划工作" Width="550"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBlock TextWrapping="Wrap" Text="{Binding PlanInfo}"></TextBlock> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn Header="创建时间" DisplayMemberBinding="{Binding Path=CreateTime,StringFormat='{}{0:yyyy年MM月dd日}',ConverterCulture=zh-CN}"/> <GridViewColumn Header="计划完成时间" DisplayMemberBinding="{Binding Path=Plane,StringFormat='{}{0:yyyy年MM月dd日}',ConverterCulture=zh-CN}"/> </GridView> </ListView.View> </ListView>
myplaneLV_MouseDoubleClick双击事件对应代码如下:
private void myplaneLV_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
DataRowView rowView = myplaneLV.SelectedItem as DataRowView;
MessageBox.Show(rowView[1].ToString());
// DataRowView rowv = (DataRowView)myplaneLV.SelectedItem;
// MessageBox.Show(myplaneLV.SelectedItem.GetType().ToString());
}
最终效果如下图:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。