I have a ListView Control witch item is composite by two TextBlocks like that:
<ListView x:Name="resultsList" ItemsSource="{Binding}" HorizontalAlignment="Left" Height="470" Margin="10,0,0,0" VerticalAlignment="Top" Width="342" FontSize="21.333" BorderThickness="0" ItemClick="RedirectPage" IsItemClickEnabled="True" SelectionMode="None">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,-4,0,-4">
<StackPanel.Resources>
<Style TargetType="TextBlock">
<Setter Property="Margin" Value="0,0,0,0" />
</Style>
</StackPanel.Resources>
<TextBlock FontSize="35" Text="{Binding target_name}" />
<TextBlock FontSize="15" Text="{Binding type_name}" Opacity="30" Margin="0, 0, 0 ,30"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
In the code behind I am trying to get as string the text value from first TextBlock element.
string targetName;
targetName = resultsList.SelectedItem.ToString();
I want that Variable "targetName" ัะพ assign the text value ( Text="{Binding target_name}" ) from first TextBlock in the ListView Item.
I will be very thankful if someone is able to help me.