Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Possible to load Constraints defined on a class into views on a RelativeLayout in xaml?

$
0
0

Can I achieve something like this:

<ContentPage.Content>


<RelativeLayout>
    <Label x:Name="Label_Name" 
        Text="First Middle and Last Name"
        Font="{x:Static local:ThemeConstants.RegisterNameLabel}"
        VerticalOptions="Center" 
        HorizontalOptions="StartAndExpand" 

        RelativeLayout.XConstraint="{x:Static local:Style.test}" 

        RelativeLayout.YConstraint="{ConstraintExpression Type=Constant,Constant=10}" 
        RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width,Factor=1.0}" 
        RelativeLayout.HeightConstraint="{ConstraintExpression Type=Constant,Constant=40}">
    </Label>
</RelativeLayout>

</ContentPage.Content>

The reason for this is that I need the positions and size of views to be loaded from configuration files, and do as little as possible modifications to code.
I tried a definition for test of ConstraintExpression and string with these values

public static string test = "{ConstraintExpression Type=Constant,Constant=0}";

public static ConstraintExpression test {
get{ return new ConstraintExpression (){ Type = ConstraintType.Constant, Constant = 50 }; }
}

but no luck.


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>