0
votes

I made Windows phone 8.1 application that displays certain events. It shows me picture, title, location and id of event. All of these events are shown in listview. Now I want to tap on specified event and show description of event on new page. Anyone know how to check which event has been tapped in listview and show his description in new page (BlankPage1.xaml)?

My class

-FSfeed.cs

public class Rootobject
{
    public Class1[] Property1 { get; set; }
}

public class Class1
{
    public string id { get; set; }
    public string title { get; set; }
    public string description { get; set; }
    public string image { get; set; }
    public string start { get; set; }
    public string end { get; set; }
    public string location { get; set; }
}

Showing events in Listview

-StartPage.xaml

            <Grid HorizontalAlignment="Left" Height="538" VerticalAlignment="Top" Width="400">
                <ListView x:Name="Reviews" Margin="0,0,0,0" Grid.Row="1" >
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}" Width="110" Height="110">
                                    <Image Source="{Binding image}" Stretch="UniformToFill" />

                                </Border>
                                <TextBlock Text=" " />
                                <StackPanel x:Name="st1" Grid.Column="1" VerticalAlignment="Top" Orientation="Vertical" Margin="10,0,0,0" >
                                    <TextBlock Text="{Binding title}" TextWrapping="Wrap"/>
                                    <StackPanel Grid.Column="1" VerticalAlignment="Top" Orientation="Horizontal" Margin="0,0,0,0">
                                        <TextBlock Margin="10,0,0,0" Text="Location:" FontWeight="Bold"/>
                                        <TextBlock Margin="10,0,0,0" Text="{Binding location}"/>
                                    </StackPanel>
                                    <StackPanel Grid.Column="1" VerticalAlignment="Top" Orientation="Horizontal" Margin="0,0,0,0">
                                        <TextBlock Margin="10,0,0,0" Text="Start:" FontWeight="Bold"/>
                                        <TextBlock Margin="10,0,0,0" Text="{Binding start}"/>
                                    </StackPanel>
                                    <StackPanel Grid.Column="1" VerticalAlignment="Top" Orientation="Horizontal" Margin="0,0,0,0">
                                        <TextBlock Margin="10,0,0,0" Text="Id:" FontWeight="Bold"/>
                                        <TextBlock Margin="10,0,0,0" Text="{Binding id}"/>
                                    </StackPanel>
                                </StackPanel>
                            </StackPanel>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
            </Grid>

Navigate user to new page(BlankPage1) when listview item is tapped

-StartPage.xaml.cs

    private void Reviews_Tapped(object sender, TappedRoutedEventArgs e)
    {
        this.Frame.Navigate(typeof(BlankPage1));

        //check which event has been tapped and show his description on BlankPage1.xaml ?

    }
1

1 Answers

1
votes

Ok i found answer after couple hours of researching...

Add the following code to StartPage.xaml.cs

    private void Reviews_Tapped(object sender, TappedRoutedEventArgs e)
    {

        Class1 myobject = Reviews.SelectedItem as Class1;

        Frame.Navigate(typeof(BlankPage1), myobject);

    }

Than create textblock on target page (BlankPage1) and add the following code:

    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        var myObject = (Class1) e.Parameter;
        textblock.Text = myObject.title;
    }