Я занимаюсь разработкой приложения для Windows Phone.
У меня есть следующий код C #:
private void Default_Loaded(object sender, RoutedEventArgs e)
{
long gameId;
short gameType;
loadedData = XDocument.Load("SampleData/GamesDesc.xml");
if (NavigationContext.QueryString.Count == 2)
{
if (long.TryParse(NavigationContext.QueryString.Values.First(), out gameId))
{
if (short.TryParse(NavigationContext.QueryString.Values.Last(), out gameType))
{
var filteredData = from c in loadedData.Descendants("gameDescription")
where c.Attribute("game_id").Value == gameId.ToString() &&
c.Attribute("gameType").Value == gameType.ToString() &&
c.Attribute("language").Value.Equals(CultureInfo.CurrentCulture.TwoLetterISOLanguageName)
select new SampleData.GameDesc()
{
Id = uint.Parse(c.Attribute("game_id").Value),
Name = c.Attribute("name").Value,
Language = c.Attribute("language").Value,
GameType = uint.Parse(c.Attribute("gameType").Value),
ShortDescription = c.Attribute("shortDescription").Value,
LongDescription = c.Attribute("longDescription").Value
};
LayoutRoot.DataContext = filteredData;
}
}
}
}
И следующий код XAML:
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Grid x:Name="LongDescPanel" Margin="0">
<Grid.RowDefinitions>
<RowDefinition Height="0.45*"/>
<RowDefinition Height="0.55*"/>
</Grid.RowDefinitions>
<TextBlock x:Name="LongDescription" Margin="8,8,8,13" TextWrapping="Wrap" Text="{Binding LongDescription}"/>
<Button x:Name="PlayButton" Content="{Binding Path=AppResources.Play, Source={StaticResource LocalizedStrings}}" VerticalAlignment="Top" Margin="165,36,165,0" d:LayoutOverrides="Width" Grid.Row="1" Click="PlayButton_Click" />
</Grid>
</Grid>
</Grid>
Почему LongDescription
TextBlock ничего не показывает?