我想在绑定列表框中的“GameName”文本块后访问文本内容。
<controls:PanoramaItem Header="games" Margin="0" Height="800" Foreground="White" VerticalAlignment="Center">
<!--Double line list with text wrapping-->
<ListBox x:Name="GamesListBox" Margin="0,0,-12,66" Height="614" ItemsSource="{Binding dataFeed}" SelectionChanged="GamesListBox_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0,0,0,17">
<!--Replace rectangle with image-->
<Image Height="100" Width="100" Source="{Binding AllGamesImage}" Margin="12,0,9,0" VerticalAlignment="Top" HorizontalAlignment="Left" Stretch="UniformToFill" />
<StackPanel Width="311">
<TextBlock x:Name="GameName" Text="{Binding AllGamesTitle}" TextWrapping="Wrap" Foreground="White" Style="{StaticResource PhoneTextExtraLargeStyle}" Margin="0,0,0,1"/>
<TextBlock Text="{Binding AllGamesDescription}" TextWrapping="Wrap" Margin="0,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</controls:PanoramaItem>
我想将任何设置为文本内容并将其作为参数或任何内容传递到另一个页面。
Shawn Kendrot 建议后的代码。
private void GamesListBox_SelectionChanged(object sender, EventArgs e)
{
var myObject = GamesListBox.SelectedItem as NewGamesClass;
string gameName = myObject.TitleCode;
NavigationService.Navigate(new Uri("/Pages/AchivementListPage.xaml?gameName=" + gameName, UriKind.Relative));
}
返回此处的页面时,我得到一个 NullExeception:
字符串游戏名称 = myObject.TitleCode;