如何将LinearGradientBrush
添加为App.xaml
的ResourceDictionary
中的ContentPage.Background
?我的代码粘贴在下面:
<LinearGradientBrush EndPoint="0,1">
<GradientStop Color="LightBlue"
Offset="0.1" />
<GradientStop Color="DarkBlue"
Offset="1.0" />
</LinearGradientBrush>
由于LinearGradientBrush是一个预览概念,请不要忘记在App.xaml.cs
中添加以下代码。
Device.SetFlags(new string[] {"Brush_Experimental" });
并将以下内容添加到App.xaml
:
<Application.Resources>
<ResourceDictionary>
<Style TargetType="ContentPage" ApplyToDerivedTypes="True">
<Setter Property="Background">
<LinearGradientBrush EndPoint="0,1">
<GradientStop Color="LightBlue"
Offset="0.1" />
<GradientStop Color="DarkBlue"
Offset="1.0" />
</LinearGradientBrush>
</Setter>
</Style>
</ResourceDictionary>
</Application.Resources>