如何仅在Xamarin Forms XAML中设置左页边距? [英] How to set a left margin only in 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.
推荐答案
解决方案是创建
以相同的方式对 Declare this in the same way for
来源:
Sources: 这篇关于如何仅在Xamarin Forms XAML中设置左页边距?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!Bottom
,Top
和Right
进行声明.然后像这样在XAML中使用它: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
* https://forums.xamarin.com/discussion/66026/use-attached-bindable-property-in-xaml
* https://stackoverflow.com/a/32408461/2550406