xfgloss
xfgloss copied to clipboard
ChildStep is set more than once error?
Hello, I have installed XFGloss and when I try to add a gradient step within my xaml file, i get a XAML error telling me that: "The property 'ChildStep' is set more than once."
must likely I forgot a step or two, any help would be great. note: It does work in the code behind.
Visual studio 2017 Xamarin Forms 3.5.0.129452
here is my XAML code:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:xfg="clr-namespace:XFGloss;assembly=XFGloss"
NavigationPage.HasNavigationBar="false"
x:Class="amici.Logon">
<xfg:ContentPageGloss.BackgroundGradient>
<xfg:Gradient Rotation="150">
<xfg:GradientStep StepColor="White" StepPercentage="0" />
<xfg:GradientStep StepColor="White" StepPercentage=".5" />
<xfg:GradientStep StepColor="#ccd9ff" StepPercentage="1" />
</xfg:Gradient>
</xfg:ContentPageGloss.BackgroundGradient>
Is the sample code incorrect?
I believe there has been a change made to XF that causes this to no longer work. Previously, it was possible to automatically assign gradient steps to a collection by using a custom setter on the designated content property for the Gradient class. See the comments in the source for details. https://github.com/tbaggett/xfgloss/blob/dc31278319bad836fc75ef23cd0472d5ead56e5b/src/XFGloss/Shared/Elements/Gradient.cs#L476
I will investigate the issue further to see if I can make the convenience property work again. In the meantime, you should wrap the GradientStep declarations inside an xfg:Gradient.Steps tag like this:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:XFGlossTest" xmlns:xfg="clr-namespace:XFGloss;assembly=XFGloss" x:Class="XFGlossTest.MainPage">
<xfg:ContentPageGloss.BackgroundGradient>
<xfg:Gradient Rotation="150">
<xfg:Gradient.Steps>
<xfg:GradientStep StepColor="White" StepPercentage="0" />
<xfg:GradientStep StepColor="White" StepPercentage=".5" />
<xfg:GradientStep StepColor="#ccd9ff" StepPercentage="1" />
</xfg:Gradient.Steps>
</xfg:Gradient>
</xfg:ContentPageGloss.BackgroundGradient>
<StackLayout>
<!-- Place new controls here -->
<Label Text="Welcome to Xamarin.Forms!"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
</StackLayout>
I created a new project, added the gradient and verified it worked.
@tbaggett Thanks for this!