我正在尝试在https://developer.xamarin.com/guides/xamarin-forms/themes/custom/之后创建自定义主题,但目前还不清楚如何通过主题设置网页的背景颜色。
我尝试过创建一个以ContentPage为目标的隐式样式。我还尝试为ContentPage创建一个样式类。两者都不起作用。它不起作用,因为加载的实际页面不是ContentPage,而是子类化页面。在https://bugzilla.xamarin.com/show_bug.cgi?id=27659 Jason Smith声明"隐式样式不适用于子类。"
我很乐意看一下Xamarin.Forms.Themes的来源,看看Forms团队是如何做到的,但它似乎并不适用于GitHub。
答案 0 :(得分:0)
@JoshuaLatusia说: 嗨,我发现这适用于我的所有页面。 通过使用" ApplyToDerivedTypes"您将为所有内容页面设置通用样式。 例如:
<Style TargetType="ContentPage" ApplyToDerivedTypes="True"> <Setter Property="BackgroundColor" Value="#eeecf6" /> </Style>
请参阅https://forums.xamarin.com/discussion/comment/302323/#Comment_302323