0

I'm working on a project in which I'm setting content using JSON Binding in Grid view but now I want to get Text of item when it is selected. XAML CODE:

 <GridView ItemsSource="{Binding}"   HorizontalAlignment="Center" Margin="0,10,0,0" x:Name="dataList" VerticalAlignment="Center" SelectionMode="None" SelectionChanged="dataList_Selection">
        <GridView.ItemTemplate>
            <DataTemplate>
                <StackPanel Width="450" Height="300">
                    <Image Source="{Binding Top}"  Margin="0,0,0,0" Stretch="None" />
                    <TextBlock x:Name="title" Text="{Binding Title}"   Foreground="Black" HorizontalAlignment="Center" FontFamily="Assets/Font/MixBrush.ttf#MixBrush"  FontWeight="Bold" FontSize="50" Margin="0,10,0,0"  />
                <Image Source="{Binding Bottom}" Margin="0,0,0,0" Stretch="None" />
                    <TextBlock  Text="{Binding first}"   Foreground="Black" HorizontalAlignment="Center"  FontFamily="Assets/Font/Comfortaa_Regular.ttf#Comfortaa"   FontSize="20" Margin="0,50,0,0"  />
                    <TextBlock Text="{Binding second}"   Foreground="Black" HorizontalAlignment="Center"  FontFamily="Assets/Font/Comfortaa_Regular.ttf#Comfortaa"   FontSize="20" Margin="0,0,0,0"  />
                    <TextBlock Text="{Binding third}"   Foreground="Black" HorizontalAlignment="Center"  FontFamily="Assets/Font/Comfortaa_Regular.ttf#Comfortaa"   FontSize="20" Margin="0,0,0,0"  />
                </StackPanel>
            </DataTemplate>
        </GridView.ItemTemplate>
    </GridView>

Here I want to get Text of "title" programmatically. Please share your knowledge with me. :-)
********************** Thank You ************************

Mohammad Hani
  • 459
  • 5
  • 14

2 Answers2

0

On your back code use:

title.Text;
SᴇM
  • 7,024
  • 3
  • 24
  • 41
0

After long hard struggle I found my answer.

var selection = (myClass) dataList.SelectedItem;
await new MessageDialog(selection.Title).ShowAsync();

And I got perfect result.

Thank You.

Mohammad Hani
  • 459
  • 5
  • 14