0
votes

I would like to specify the width of a Xamarin.Forms.Button with an effect in UWP, something like:

protected override void OnAttached()
{
    if (VisualElement is Xamarin.Forms.Button buttonControl)
    {
        buttonControl.WidthRequest = 40;
        buttonControl.BorderWidth = 1;
    }
}

VisualElement is an invalid type. What goes in its place? Thank you!

1

1 Answers

1
votes

Xamarin Forms UWP specifying button width request with an effect

In Xamarin effect class, the attached control is referenced with Element property but not VisualElement, please edit your code like the following and you will get forms button on OnAttached method.

protected override void OnAttached()
{
    if (Element is Xamarin.Forms.Button buttonControl)
    {
        buttonControl.WidthRequest = 40;
        buttonControl.BorderWidth = 1;
    }      
}