无法在ListView中选择一行

时间:2013-06-29 02:41:03

标签: wpf listview

我无法在列表项

中选择一行

这是我的代码

<Grid DockPanel.Dock="Left" MinWidth="250">
 <ListView x:Name="ListVendors" ItemsSource="{Binding SourceCollection}">
  <ListView.View>
   <GridView>
    <GridView.ColumnHeaderContainerStyle>
     <Style><Setter Property="FrameworkElement.Visibility" Value="Collapsed"/></Style>
    </GridView.ColumnHeaderContainerStyle>
    <GridViewColumn>
     <GridViewColumn.CellTemplate>
      <DataTemplate>
       <Grid>
        <Grid.RowDefinitions>
         <RowDefinition />
         <RowDefinition />
         <RowDefinition />
        </Grid.RowDefinitions>
        <TextBlock Grid.Row="0" Text="{Binding Name}" FontSize="20"/>
        <TextBlock Grid.Row="1" Text="{Binding Code}" Foreground="Gray" />
        <TextBlock Grid.Row="2" Text="{Binding ContactNo}" Foreground="Gray" />
       </Grid>
      </DataTemplate>
     </GridViewColumn.CellTemplate>
    </GridViewColumn>
    <GridViewColumn>
     <GridViewColumn.CellTemplate>
      <DataTemplate>
       <Grid>
        <Grid.RowDefinitions>
         <RowDefinition />
        </Grid.RowDefinitions>
        <TextBlock Grid.Row="0" Text="{Binding Path=Address, Converter={StaticResource addNewLineConv}}" Grid.RowSpan="3" />
       </Grid>
      </DataTemplate>
     </GridViewColumn.CellTemplate>
    </GridViewColumn>
    <GridViewColumn>
     <GridViewColumn.CellTemplate>
      <DataTemplate>
       <Grid>
        <Grid.RowDefinitions>
         <RowDefinition />
        </Grid.RowDefinitions>
        <TextBlock Grid.Row="2" Text="{Binding Email}"/>
       </Grid>
      </DataTemplate>
     </GridViewColumn.CellTemplate>
    </GridViewColumn>
   <GridViewColumn DisplayMemberBinding="{Binding Email}" Header="Email"/>
  </GridView>
 </ListView.View>
</ListView>

如何在ListView中选择一行?

0 个答案:

没有答案