【问题标题】:Xamarin Forms UWP specifying button width request with an effectXamarin Forms UWP 指定具有效果的按钮宽度请求
【发布时间】:2020-04-14 19:19:45
【问题描述】:

我想在 UWP 中指定具有效果的 Xamarin.Forms.Button 的宽度,例如:

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

VisualElement 是无效类型。取而代之的是什么?谢谢!

【问题讨论】:

    标签: xamarin.forms uwp


    【解决方案1】:

    Xamarin Forms UWP 指定按钮宽度请求的效果

    在 Xamarin 效果类中,附加的控件使用 Element 属性而不是 VisualElement 引用,请像下面这样编辑您的代码,您将在 OnAttached 方法上获得表单按钮。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-08-11
      • 1970-01-01
      • 1970-01-01
      • 2021-03-14
      • 2019-09-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多