後續的使用例如XAML from this rather incomplete post通過@Tomasz科瓦爾奇克尖端:
在App.xaml中的ResourceDictionary把這個風格:
<Style x:Key="defaultPageStyle" TargetType="ContentPage">
<Setter Property="BackgroundColor" Value="#f8f8f8"/>
</Style>
基類被稱爲BaseContentPage
public class BaseContentPage : ContentPage
{
public BaseContentPage()
{
var style = (Style)Application.Current.Resources["defaultPageStyle"];
Style = style;
}
}
然後將它們全部綁定在每個xaml.cs類中:
namespace MyNamespace
{
public partial class MyXamlPage: BaseContentPage
而且文件名爲.xaml
<local:BaseContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MyNamespace;assembly=MyNamespace"
x:Class="MyNamespace.MyXamlPage"
請閱讀這篇文章,它可能是有用的,還有與此相關的一個bug,一些解決方法過於https://forums.xamarin.com/discussion/34798/how添加全局背景顏色風格 –
我試過這個,但是我很困難,然後搞清楚我的主頁中的xaml會是什麼樣子 – paqogomez
@TomaszKowalczyk,謝謝你的幫助。你指出我正確的道路。 – paqogomez