【发布时间】:2017-01-03 10:59:19
【问题描述】:
当我在应用程序资源文件中设置内容页面填充时,使用 Prism.Forms 6.2 和 Xamarin.Forms 2.3.3.118 pre-1 时,它不会仅针对内容页面填充全局遵循。所有其他资源属性都正确流动。这是我的 app.xaml 代码:
<?xml version="1.0" encoding="utf-8"?>
<prism:PrismApplication xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyNamespace.App"
xmlns:prism="clr-namespace:Prism.Unity;assembly=Prism.Unity.Forms"
xmlns:local="clr-namespace:MyNamespace;assembly=MyNamespace">
<prism:PrismApplication.Resources>
<!-- Application resource dictionary -->
<ResourceDictionary>
<converter:DebuggingConverter x:Key="localDebuggingConverter"/>
<local:ItemTappedEventArgsToItemTappedConverter x:Key="SelectedItemConverter" />
<Style TargetType="Label">
<Setter Property="FontSize" >
<Setter.Value>
<!--iOS default is 17 and is not the same size as android 14. If FontSize is left at default it will be larger on iOS than android-->
<OnPlatform x:TypeArguments="x:Double"
iOS="14"
Android="14">
</OnPlatform>
</Setter.Value>
</Setter>
<Setter Property="VerticalOptions" Value="Center">
</Setter>
</Style>
<Style TargetType="ContentPage">
<Setter Property="Padding">
<Setter.Value>
<OnPlatform x:TypeArguments="Thickness"
iOS="5, 28, 5, 5"
Android="5, 8, 5, 5"
WinPhone="5, 8, 5, 5" />
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</prism:PrismApplication.Resources>
</prism:PrismApplication>
这是我的 xaml 视图:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
xmlns:local="clr-namespace:MyNamespace;assembly=MyNamespace"
prism:ViewModelLocator.AutowireViewModel="True"
x:Class="MyNamespace.Views.ChooseProfileView">
<!--<ContentPage.Padding>
If I set the content padding this way it is rendered correctly. When this is commented out as it is now the padding is not set by the application resource (implicit style).
<OnPlatform x:TypeArguments="Thickness"
iOS="5, 28, 5, 5"
Android="5, 8, 5, 5"
WinPhone="5, 8, 5, 5" />
</ContentPage.Padding> -->
<ContentPage.Content>
<!-- whatever content. The padding set here is displayed correctly-->
</ContentPage.Content>
</ContentPage>
有什么想法吗?
【问题讨论】:
标签: xaml xamarin.forms prism