【发布时间】:2016-07-13 08:52:22
【问题描述】:
我有以下代码:
<StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand" Margin="0,10,0,10" BackgroundColor="Green" Padding="5,5,5,5">
<StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand" Margin="0,0,0,0" BackgroundColor="Blue">
<Label Text="SHOW COMPLETED TASKS" BackgroundColor="Red" Style="{StaticResource lblSubHeading_Black}" />
</StackLayout>
<Switch x:Name="CompletedJobsSwitch" Toggled="CompletedJobsSwitch_Toggled" HorizontalOptions="EndAndExpand" IsToggled="{Binding isOn}" BackgroundColor="Yellow"/>
</StackLayout>
一切正常,但是当应用程序加载时它会显示,但 Switch 不正确。为什么?真的很烦,好像真的很不协调 我看过 http://forums.xamarin.com/discussion/21226/how-to-right-align-a-view-inside-a-list-item 但这对我不起作用。
有什么想法吗?
【问题讨论】:
-
并不矛盾。
StackLayout只占用所需的空间。尝试在其最高级别周围放置Grid。 -
当我说不稳定时,我的意思是 Xamarin 表单的 XAML,但我将 StackLayout 设置为填充和扩展,为什么不这样做?添加网格似乎是在解决问题。
-
您不必添加网格,只需将您的顶级 StackLayout 替换为网格即可。
标签: c# xaml xamarin xamarin.forms