I have a ListView in a .xaml window and in it are a list of entries. Here is the important code:
<ListView Grid.Row="1" Name="findList" BorderThickness="0" Margin="-4,26,-4,-4">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<EventSetter Event="MouseDoubleClick" Handler="OnFindItem"></EventSetter>
</Style>
</ListView.ItemContainerStyle>
<ListView.View>
<GridView>
<GridViewColumn Header="ID" DisplayMemberBinding="{Binding Path=ID}" Width="32"/>
<GridViewColumn Header="Key" DisplayMemberBinding="{Binding Path=Key}" Width="140"/>
<GridViewColumn Header="English" DisplayMemberBinding="{Binding Path=English}" Width="250"/>
<GridViewColumn Header="Translated Language" DisplayMemberBinding="{Binding Path=Translation}" Width="250"/>
</GridView>
</ListView.View>
</ListView>
When a user double clicks on one of the entries it goes to OnFindItem in my C# file. The specific block of code for it is (although completely broken) here:
private void OnFindItem(object sender, RoutedEventArgs e)
{
ListViewItem output = e.Source as ListViewItem;
if (output != null)
{
//More code here.
}
}
No matter what I seem to adjust in this little bit of code in C#, I don’t seem to be able to read the contents of the row the user double clicked on. I’ve checked many web pages including pages on SO and MSDN and the such for solutions, but being very new to C# I just cannot see what I’m supposed to do here.
Thanks in advance, anyone that is able to help!
I finally found the solution to my problem. The C# code should have been as follows: