I've got a control on screen that needs a relative layout that has a Constant that needs to be calculated.
So My XConstraint looks like this.
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ReferenceLegend, Property=Width, Constant={localization:CalculateValue (ReferenceLegend.Width - 40)}}"
and I've started wiring up an IMarkupExtension
[ContentProperty("Input")]
public class CalculateValueExtension : IMarkupExtension
{
public string Input { get; set; }
public object ProvideValue(IServiceProvider serviceProvider)
{
var expression = Input; // "(ReferenceLegend.Width - 40)"
return // calculation.
}
}
But what I need to know is how I might dig into the serviceProvider in order to locate the ReferenceLegend.Width
, and then convert the string (ReferenceLegend.Width - 40)
into something I can evaluate.
Side note: Am I over complicating this? Is there something already wired in?