Xamarin Forms ConstraintExpressions - Can i do expressions in Xaml?

Viewed 141

I have a horizontal Listview but to center it on any device i would have to set the XConstraint and the YConstraint to:(ParentWidth * 0.5) - (ParentHeight * 0.5)

Is there any way of doing this in Xaml or does this have to be done in code ?

Best I could come up with was this (I am an Xamarin rookie):

1. RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.5, Constant={ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.5}}"

or :

2. RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.5} - {ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.5} "
0 Answers
Related