Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin.forms 应用程序资源无法使用静态资源/静态扩展_Xamarin.forms_Prism - Fatal编程技术网

Xamarin.forms 应用程序资源无法使用静态资源/静态扩展

Xamarin.forms 应用程序资源无法使用静态资源/静态扩展,xamarin.forms,prism,Xamarin.forms,Prism,你好!我正在使用Prism 7.2和Xamarin.Forms 4.2,并且我正在尝试使用字体的外部资源。我已经在我的应用程序资源中定义了它们,并在我的xaml代码中使用了它们,但是,当我尝试使用静态扩展名{x:static}作为文本的值,并使用同样具有静态资源扩展名{StaticResource}的样式时,文本似乎不起作用。下面是我正在使用的代码 <prism:PrismApplication.Resources> <ResourceDictionary>

你好!我正在使用Prism 7.2和Xamarin.Forms 4.2,并且我正在尝试使用字体的外部资源。我已经在我的应用程序资源中定义了它们,并在我的xaml代码中使用了它们,但是,当我尝试使用静态扩展名{x:static}作为文本的值,并使用同样具有静态资源扩展名{StaticResource}的样式时,文本似乎不起作用。下面是我正在使用的代码

 <prism:PrismApplication.Resources>
    <ResourceDictionary>
        <OnPlatform x:Key="LineAwesomeFontFamily" x:TypeArguments="x:String">
            <On Platform="Android" Value="line-awesome.ttf#LineAwesome"/>
            <On Platform="iOS" Value="lineawesome"/>
        </OnPlatform>
        <Style x:Key="LineAwesomeFonts"
               TargetType="Label">
            <Setter Property="FontFamily"
                Value="{StaticResource LineAwesomeFontFamily }" />
        </Style>

        <Style TargetType="Button">
            <Setter Property="BackgroundColor" Value="Green"/>
        </Style>
    </ResourceDictionary>

</prism:PrismApplication.Resources>
在视图中调用它

<Label Text="{x:Static fonts:LineAwesomeFonts.Adjust}"
       Style="{StaticResource LineAwesomeFonts}"
       TextColor="Black">
</Label>
如果我用另一种方式尝试

 <Label x:Name="testLabel"
        FontSize="28" TextColor="Black">
        <Label.FontFamily>
            <OnPlatform x:TypeArguments="x:String">
                <On Platform="Android" Value="line-awesome.ttf#LineAwesome"/>
            </OnPlatform>
        </Label.FontFamily>
  </Label>
并调用xaml.cs上的testLabel,使其具有一个可以工作的值

知道我做错了什么吗?编译时没有发现错误。

好的,这是我的错

 public App(IPlatformInitializer platformInitializer) : base(platformInitializer)
 {}


 protected override void OnInitialized()
 {
     InitializeComponent(); //moved this away from App constructor and put it here
     NavigationService.NavigateAsync("Test");
 }
虽然这很奇怪,因为我的初始化组件;另一个项目是在应用程序构造函数上,资源按预期工作