我希望每个内容页面都包含以下元素
<xfg:ContentPageGloss.BackgroundGradient>
<xfg:Gradient Rotation="170">
<xfg:GradientStep StepColor="#9DCC5F" StepPercentage="0" />
<xfg:GradientStep StepColor="#00B0CD" StepPercentage="1" />
</xfg:Gradient>
</xfg:ContentPageGloss.BackgroundGradient>
我该怎么办?
答案 0 :(得分:0)
为什么不创建ContentPage
的重载?
创建一个文件,例如GlossContentPage
。
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:xfg="clr-namespace:XFGloss;assembly=XFGloss"
x:Class="YourApp.Pages.GlossContentPage">
<xfg:ContentPageGloss.BackgroundGradient>
<xfg:Gradient Rotation="170">
<xfg:GradientStep StepColor="#9DCC5F" StepPercentage="0" />
<xfg:GradientStep StepColor="#00B0CD" StepPercentage="1" />
</xfg:Gradient>
</xfg:ContentPageGloss.BackgroundGradient>
</ContentPage>
现在开始使用新的GlossContentPage
,而不是常规ContentPage
,例如:
<pages:GlossContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:pages="clr-namespace:YourApp.Pages;assembly=YourApp"
x:Class="YourApp.Pages.MyNewShinyPage">
<Label Text="Welcome to Xamarin.Forms" HorizontalOptions="Center" VerticalOptions="Center" />
</pages:GlossContentPage>