xfgloss icon indicating copy to clipboard operation
xfgloss copied to clipboard

ChildStep is set more than once error?

Open colonna-mike opened this issue 6 years ago • 3 comments

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>

colonna-mike avatar Feb 11 '19 14:02 colonna-mike

Is the sample code incorrect?

LeoJHarris avatar Mar 26 '19 02:03 LeoJHarris

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 avatar Mar 26 '19 19:03 tbaggett

@tbaggett Thanks for this!

adamhalesworth avatar Jan 29 '20 10:01 adamhalesworth