【发布时间】:2015-04-20 15:32:28
【问题描述】:
我制作了显示某些事件的 Windows phone 8.1 应用程序。它向我显示了事件的图片、标题、位置和 ID。所有这些事件都显示在列表视图中。现在我想点击指定事件并在新页面上显示事件描述。任何人都知道如何检查在列表视图中点击了哪个事件并在新页面(BlankPage1.xaml)中显示他的描述?
我的班级
-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; }
}
在列表视图中显示事件
-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>
点击列表视图项时将用户导航到新页面(BlankPage1)
-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 ?
}
【问题讨论】:
标签: c# wpf visual-studio listview windows-phone-8.1