Hi guys, anyone can help me?
I'm getting this error and when I look my StackTrace, I've got this error: Xamarin.Forms.Xaml.MarkupExtensionParser.SetPropertyValue
Here is the code I'm using, just for test:
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace Essilor.Support
{
public abstract class RelativeToView : IMarkupExtension
{
protected RelativeToView()
{
Factor = 1;
}
public string PropertyName { get; set; }
public string ElementName { get; set; }
public double Factor { get; set; }
public double Constant { get; set; }
public object ProvideValue( IServiceProvider serviceProvider )
{
var element = new ReferenceExtension { Name = ElementName }.ProvideValue( serviceProvider ) as View;
if ( element != null )
{
var result = Constraint.RelativeToView( element, ( layout, view ) => DeterminePosition( view ) + Constant );
return result;
}
return null;
}
protected virtual double DeterminePosition( VisualElement view )
{
var result = DetermineStart( view ) + DetermineExtent( view ) * Factor;
return result;
}
protected abstract double DetermineExtent( VisualElement view );
protected abstract double DetermineStart( VisualElement view );
}
}
using System;
using Xamarin.Forms;
namespace Essilor.Support
{
public class BelowOf: RelativeToView
{
protected override double DetermineExtent( VisualElement view )
{
return view.Height;
}
protected override double DetermineStart( VisualElement view )
{
return view.Y;
}
}
}
And here is the XAML which is causing the error:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:support="clr-namespace:Essilor.Support;assembly=Essilor"
x:Class="Essilor.Views.LoginView"
BackgroundColor="White">
<RelativeLayout Grid.Row="1">
<Image x:Name="logo"
Aspect="Fill"
RelativeLayout.XConstraint=
"{ConstraintExpression Type=Constant,
Constant=0}"
RelativeLayout.YConstraint=
"{ConstraintExpression Type=Constant,
Constant=0}"
RelativeLayout.WidthConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=1}"
RelativeLayout.HeightConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=0.5}"
Source="logo.png" />
<Label
x:Name="labelAccessKey"
Text="Chave de Acesso"
TextColor="Black"
XAlign="End"
RelativeLayout.XConstraint=
"{ConstraintExpression Type=Constant,
Constant=0}"
RelativeLayout.YConstraint=
"{ConstraintExpression Type=RelativeToView,
ElementName=logo,
Property=Height,
Constant=40}"
RelativeLayout.WidthConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=0.40}"
/>
<Entry
x:Name="accessKey"
RelativeLayout.XConstraint=
"{ConstraintExpression Type=RelativeToView,
ElementName=labelAccessKey,
Property=Width,
Constant=10}"
RelativeLayout.YConstraint=
"{ConstraintExpression Type=RelativeToView,
ElementName=labelAccessKey,
Property=Y,
Constant=-15}"
RelativeLayout.WidthConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=0.5}"
/>
<Label
x:Name="labelPassword"
Text="Senha"
TextColor="Black"
XAlign="End"
RelativeLayout.XConstraint=
"{ConstraintExpression Type=Constant,
Constant=0}"
RelativeLayout.YConstraint=
"{ConstraintExpression Type=RelativeToView,
ElementName=logo,
Property=Height,
Constant=80}"
RelativeLayout.WidthConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=0.40}"
/>
<Entry
x:Name="password"
RelativeLayout.XConstraint=
"{ConstraintExpression Type=RelativeToView,
ElementName=labelPassword,
Property=Width,
Constant=10}"
RelativeLayout.YConstraint=
"{ConstraintExpression Type=RelativeToView,
ElementName=labelPassword,
Property=Y,
Constant=-15}"
RelativeLayout.WidthConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=0.5}"
/>
<Label
x:Name="forgotPassword"
Text="Esqueceu!"
TextColor="Blue"
XAlign="End"
RelativeLayout.XConstraint=
"{ConstraintExpression Type=RelativeToView,
ElementName=password,
Property=X,
Constant=0}"
RelativeLayout.YConstraint=
"{support:BelowOf Type=RelativeToView,
ElementName=password}"
/>
<Button
Text = "Cadastrar"
RelativeLayout.XConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=0.5}"
RelativeLayout.YConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Height,
Constant=-50}"/>
</RelativeLayout>
</ContentPage>