I have listview in wpf C#.net,
How can I get row id from this listview on click?
- <ListView Height="490"
- HorizontalAlignment="Left"
- Name="listView1"
- VerticalAlignment="Top"
- Width="780"
- ItemsSource="{Binding}"
- IsSynchronizedWithCurrentItem="True"
- Margin="10,48,0,10">
- <ListView.View>
- <GridView>
-
- <GridView.Columns >
- <GridViewColumn>
- <GridViewColumn.CellTemplate>
- <DataTemplate>
- <CheckBox Tag="{Binding login_Id}" />
- </DataTemplate>
- </GridViewColumn.CellTemplate>
- </GridViewColumn >
- <GridViewColumn Width="155px" DisplayMemberBinding="{Binding FirstName}" >
- <GridViewColumn.Header>
- <GridViewColumnHeader Tag="FirstName" Click="MenuItem_Click">User Name</GridViewColumnHeader>
- </GridViewColumn.Header>
- </GridViewColumn>
- <GridViewColumn Width="155px" DisplayMemberBinding="{Binding Computer_Name}" Header="PC-Names" />
- <GridViewColumn Width="154px" DisplayMemberBinding="{Binding IP_Address}" Header="IP Adress" />
- <GridViewColumn Width="153px" DisplayMemberBinding="{Binding countID}">
- <GridViewColumn.Header>
- <GridViewColumnHeader Tag="countID" Click="MenuItem_Click">Documents Scanned</GridViewColumnHeader>
- </GridViewColumn.Header>
- </GridViewColumn>
- <GridViewColumn Width="153px" DisplayMemberBinding="{Binding LogInTime}" >
- <GridViewColumn.Header>
- <GridViewColumnHeader Tag="LogInTime" Click="MenuItem_Click">Last Login</GridViewColumnHeader>
- </GridViewColumn.Header>
- </GridViewColumn>
- </GridView.Columns>
- </GridView>
- </ListView.View>
- <ListView.ItemContainerStyle>
- <Style TargetType="ListViewItem">
- <EventSetter Event="PreviewMouseLeftButtonDown" Handler="ListViewItem_PreviewMouseLeftButtonDown" />
- </Style>
- </ListView.ItemContainerStyle>
- </ListView>
-
I have tried,
- private void ListViewItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
-
- }