【问题标题】:Xamarin.Forms UWP Size of Elements doesn't workXamarin.Forms UWP 元素大小不起作用
【发布时间】:2017-09-08 10:33:50
【问题描述】:

我是 Xamarin 的新手。 当我尝试插入 Button 或 BoxView 时,我可以设置“HeightRequest”和“WidthRequest”参数,但元素只是填满了整个屏幕。 我做错了什么?

【问题讨论】:

    标签: xaml xamarin uwp xamarin.forms


    【解决方案1】:

    您没有做错任何事,但您错过了一些关键程序。您没有设置 LayoutOptionsButtonBoxView。以下代码可以影响元素大小。

    <Button Text="click me" 
     HeightRequest="44"
     WidthRequest="60" 
     VerticalOptions="Start"
     HorizontalOptions="Start"/>
    

    如您所知,按钮控件继承自ViewVerticalOptions 依赖属性的默认值为LayoutOptions.Fill。它也适用于HorizontalOptions。所以如果你没有为VerticalOptionsHorizontalOptions设置值,控件会填满整个屏幕。

    【讨论】:

    • 做到了!非常感谢:)
    猜你喜欢
    • 2023-03-05
    • 1970-01-01
    • 1970-01-01
    • 2016-08-16
    • 1970-01-01
    • 1970-01-01
    • 2019-12-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多