Windows phone 7 如何根据用户在windows phone 8中设置的语言设置文本块的外部样式
我的windows phone 8应用程序应使用英语和阿拉伯语两种语言。 在这个应用程序中,我在许多地方使用了文本块控件,例如在列表框中,以及作为单独的页面标题Windows phone 7 如何根据用户在windows phone 8中设置的语言设置文本块的外部样式,windows-phone-7,xaml,windows-phone-8,Windows Phone 7,Xaml,Windows Phone 8,我的windows phone 8应用程序应使用英语和阿拉伯语两种语言。 在这个应用程序中,我在许多地方使用了文本块控件,例如在列表框中,以及作为单独的页面标题 <!--TitlePanel contains the name of the application and page title--> <StackPanel Grid.Row="0" VerticalAlignment="Center"> <TextBlock x:Name="
<!--TitlePanel contains the name of the application and page title-->
<StackPanel Grid.Row="0" VerticalAlignment="Center">
<TextBlock x:Name="title" Text="{Binding LocalizedResources.CategoriesText, Source={StaticResource LocalizedStrings}}" Foreground="#FF501F6E" Style="{StaticResource PhoneTextNormalStyle}" FontWeight="Bold" FontSize="40" HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="Fonts/nazli.ttf#nazli"/>
</StackPanel>
现在在列表框中还有文本块
<Grid x:Name="ContentPanel" Grid.Row="2" Background="White">
<ListBox x:Name="categoriesList"
SelectionChanged="categoriesList_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid x:Name="categoryGrid" Height="60" Margin="0,0,0,0" MinWidth="480" Background="{Binding Converter={StaticResource RowColour}}" >
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
<!--<RowDefinition Height="10"/>-->
</Grid.RowDefinitions>
<StackPanel x:Name="dataRow" Grid.Row="0" Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock x:Name="category" Text="{Binding CategoryName}" Foreground="#FF501F6E" Style="{StaticResource PhoneTextNormalStyle}" HorizontalAlignment="Left" FontSize="28" MinWidth="420"/>
<Image x:Name="arrow" Stretch="Fill" Margin="0,0,0,0" Source="{Binding ArrowImageName}" Height="20" HorizontalAlignment="Right"/>
</StackPanel>
<!--<Image x:Name="line" Grid.Row="1" Width="460" HorizontalAlignment="Center" Source="Images/separator.png" />-->
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
默认情况下,应用程序使用英语。因此,当应用程序使用英语时,我希望对所有文本块使用默认字体系列Segoe WP
当用户将应用程序的语言从英语更改为阿拉伯语时,我希望对应用程序中的所有文本块使用嵌入式字体nazli.ttf
因此,我在应用程序中嵌入了一种外部字体,并将内容类型设置为“始终复制”。字体为nazli.ttf
Blow是适用于英语的外部风格。但我需要一个既适用于英语又适用于阿拉伯语的外部资源。
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<Style x:Key="NormalTextStyle" TargetType="TextBlock">
<Setter Property="FontSize" Value="30"/>
<Setter Property="FontWeight" Value="Normal"/>
<Setter Property="FontFamily" Value="Segoe WP"/>
<Setter Property="Foreground" Value="Yellow"/>
</Style>
</ResourceDictionary>
因此,外部资源文件应该如何满足上述要求。一种方法是在文本块上使用转换器:
<TextBlock FontFamily="{Binding Converter={StaticResource FontConverter}}">some text</TextBlock>
根据需要调整上述路径
转换器在某处声明为:
<converters:FontConverter x:Key="FontConverter" />
嘿,它对你有用吗。。?
<converters:FontConverter x:Key="FontConverter" />