如何仅在Xamarin Forms XAML中设置左页边距? [英] How to set a left margin only in Xamarin Forms XAML?

查看:130
本文介绍了如何仅在Xamarin Forms XAML中设置左页边距?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题与>如何设置顶部利润仅在XAML中显示?,而在Xamarin而非WPF中显示.

This question is the same as How to set a top margin only in XAML? but regarding Xamarin instead of WPF.

如何在XAML的视图上设置单个边距?

How can I set an individual margin on a view from XAML?

链接的Q& A表示默认实现始终将所有未指定的边距设置为0,即使是从代码开始也是如此.

The linked Q&A indicates that the default implementation always sets all unspecified Margins to 0, even from code.

推荐答案

解决方案是创建

以相同的方式对BottomTopRight进行声明.然后像这样在XAML中使用它:

Declare this in the same way for Bottom, Top, and Right. Then use it in XAML like this:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
         xmlns:utils="using:Sample.Utils"
         x:Class="Sample.MyContentPage">
<StackLayout
   Orientation="Vertical"
   utils:Margin.Left="{StaticResource InnerPageContentMarginLeft}">
</StackLayout>
</ContentPage>


来源:
*
https://forums.xamarin.com/discussion/66026/use-attached-bindable-property-in-xaml
* https://stackoverflow.com/a/32408461/2550406


Sources:
* https://forums.xamarin.com/discussion/66026/use-attached-bindable-property-in-xaml
* https://stackoverflow.com/a/32408461/2550406

这篇关于如何仅在Xamarin Forms XAML中设置左页边距?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆