我有两个资源字典,一个用于移动设备,一个用于平板电脑,我想使用 OnIdiom 将正确的资源字典合并到 App.xaml 中。 使用 OnPlatform 很简单,但我没有找到一种方法可以使用 OnIdiom 执行相同的操作来检查它是否是平板电脑,然后加载平板电脑文件或手机文件等。
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Margins.xaml" />
<!-- The two files below I would like to use OnIdiom to select between Tablet or Mobile -->
<ResourceDictionary Source="Resources/Styles/FixedSizesMobile.xaml"/>
<ResourceDictionary Source="Resources/Styles/FixedSizesTablet.xaml"/>
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
使用 OnPlatform 很简单,但我没有看到一种方法可以使用 OnIdiom 执行相同的操作来检查它是否是平板电脑,然后加载平板电脑文件或手机文件等。
不幸的是它不能做到这一点。我尝试使用
OnIdiom
在XAML上修改它但失败了。另外,我还发现了这个案例:In Xamarin, Use OnIdiom with OnIdiom。但它没有 MAUI 的 MergedWith
,而且 Device.Idiom
是 。
对于控件,。
您可以在 GitHub 上将其报告为问题或功能请求。