I have created listview in C# and filled it with data from SQL server. But when I assign mouse double click, I don't know how to get clicked data. Please help:
My XAML:
<ListView Name="ListViewEmployeeDetails" ItemsSource="{Binding Path=Table}" Margin="0,0,0,67" MouseDoubleClick="ListViewEmployeeDetails_MouseDoubleClick">
<ListView.Background>
<LinearGradientBrush>
<GradientStop Color="white" Offset="0"/>
</LinearGradientBrush>
</ListView.Background>
<ListView.View>
<GridView>
<GridViewColumn Width="70" Header="Číslo bytu" DisplayMemberBinding="{Binding Path=cislo_Bytu}"/>
<GridViewColumn Width="70" Header="Podlaží" DisplayMemberBinding="{Binding Path=podlazi}"/>
<GridViewColumn Width="70" Header="Účel" DisplayMemberBinding="{Binding Path=ucel}"/>
<GridViewColumn Width="70" Header="Plocha" DisplayMemberBinding="{Binding Path=plocha}"/>
<GridViewColumn Width="70" Header="Stav" DisplayMemberBinding="{Binding Path=stav}"/>
<GridViewColumn Width="70" Header="Country" DisplayMemberBinding="{Binding Path=Country}"/>
</GridView>
</ListView.View>
</ListView>
And my code:
SqlDataAdapter ad = new SqlDataAdapter();
SqlCommand cmd = new SqlCommand();
String str = "SELECT cislo_Bytu, podlazi, ucel, plocha, stav, poznamky FROM prostory";
cmd.CommandText = str;
ad.SelectCommand = cmd;
cmd.Connection = datovéPřipojení;
DataSet ds = new DataSet();
ad.Fill(ds);
ListViewEmployeeDetails.DataContext = ds.Tables[0].DefaultView;
datovéPřipojení.Close();
So my question is, what I should write into the
private void ListViewEmployeeDetails_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
// Here
}
To get the data (cislo_Bytu
) from the row which was clicked on?
Thanks,