我有一个ListView
具有以下定义的 Metro 应用程序:
<ListView Grid.Row="0" x:Name="lvData" CanDragItems="True" CanReorderItems="True" SelectionMode="Extended">
<ListView.ItemTemplate>
<DataTemplate>
<Border Padding="4,0,0,0">
<Grid Width="{Binding ElementName=lvData, Path=ActualWidth}">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="65"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" HorizontalAlignment="Stretch"/>
<TextBlock Grid.Column="1" HorizontalAlignment="Right"/>
<TextBlock Grid.Column="2" HorizontalAlignment="Right"/>
<TextBlock Grid.Column="3" HorizontalAlignment="Right"/>
<TextBlock Grid.Column="4" HorizontalAlignment="Right"/>
</Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="65"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" HorizontalAlignment="Stretch" TextTrimming="WordEllipsis"/>
<TextBlock Grid.Column="1" HorizontalAlignment="Right"/>
</Grid>
</Grid>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
我尝试KeyDown
在嵌入的不同控件上设置事件ListView's
DataTemplate
,但该事件似乎永远不会触发。
注意:如果我双击ListViewItem
,则KeyDown
触发事件。
有什么建议么?