简体   繁体   English

在Xamarin.Forms项目中选择UWP的OnPlatform时遇到问题

[英]Having issues with OnPlatform selection for UWP in Xamarin.Forms Project

Good time of day to all. 所有人的好时光。 I am working on Xamarin.Forms project, including iOS, Android and UWP parts. 我正在研究Xamarin.Forms项目,包括iOS,Android和UWP部件。 My project requires usage of different custom fonts, accessible for all devices. 我的项目要求使用所有设备都可以使用的不同自定义字体。 So I added custom fonts and I am selecting them with 所以我添加了自定义字体,并选择了

string fontName = Device.OnPlatform(
                 "RoundedLEDBoard-7",
                 "rounded_led_board-7.ttf#Rounded LED Board-7",
                 @"Assets\Fonts\rounded_led_board-7.ttf#Rounded LED Board-7");

Font names and locations are correct. 字体名称和位置正确。

On the modeling stage I used a single page solution, to prototype some of the basic functionality. 在建模阶段,我使用了单页解决方案来对一些基本功能进行原型设计。 All worked exactly as expected on all three platforms, both emulators and real test devices. 在仿真器和实际测试设备这三个平台上,所有功能均按预期工作。 However, after adding navigation capabilities and changing App.xaml.cs from 但是,在添加导航功能并将App.xaml.cs从

MainPage = new Different_fonts.MainPage();

to

MainPage = new NavigationPage(new Different_fonts.MainPage());

I have discovered, that the font is not loaded (or displayed?) in UWP part of the project. 我发现,该字体未在项目的UWP部分中加载(或显示?)。 Android and iOS parts look as expected. Android和iOS部件的外观符合预期。 Complete re-build of the entire solution did not help. 完整重新构建整个解决方案没有帮助。 Does any one know where the problem is and what is the cure remedy? 有谁知道问题出在哪里以及什么治疗方法?

It looks like you found quite an odd bug! 您似乎发现了一个奇怪的错误! I am also seeing this issue with a sample project using Forms 2.3.3. 在使用Forms 2.3.3的示例项目中,我也看到了此问题。 As you mentioned, iOS and Android don't experience this issue so this should work on UWP as well. 如您所述,iOS和Android不会遇到此问题,因此这也应适用于UWP。

Unfortunately I don't have a workaround for this in the meantime, but I've filed a bug report so we can look into this. 不幸的是,在此期间,我没有针对此问题的解决方法,但我已提交了错误报告,因此我们可以对此进行调查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM