我正在尝试确定以下C#代码为什么没有得到与XAML版本相同的输出(上图是XAML,下图是后面的代码)。所有参数都具有相等的值,并且我已经嵌套了我的堆栈布局,而且我不确定将两个输出等同起来会缺少什么。任何帮助将非常感激。谢谢!
以下是XAML代码:
<StackLayout Orientation="Horizontal" Spacing="0">
<StackLayout BackgroundColor="#3d4f7c" WidthRequest="50" HeightRequest="50" VerticalOptions="Start">
</StackLayout>
<StackLayout HorizontalOptions="FillAndExpand" Padding="0" BackgroundColor="White">
<Frame HasShadow="True" CornerRadius="0" BackgroundColor="#ededef" Padding="6">
<Label TextColor="Black" Text="This is text"></Label>
</Frame>
</StackLayout>
</StackLayout>
这是背后的代码:
var Description = new StackLayout { HorizontalOptions = LayoutOptions.FillAndExpand, Padding = new Thickness(6, 6, 6, 6), BackgroundColor = Color.White };
var Frame = new Frame { Content = new Label { Text = "This is a long text", TextColor = Color.Black }, BackgroundColor = Color.FromHex("ededef"), CornerRadius = 0 };
Description.Children.Add(Frame);
var Step = new StackLayout {WidthRequest = 50, HeightRequest=50, VerticalOptions=LayoutOptions.Start, BackgroundColor=Color.FromHex("3d4f7c") };
var StepDisplay = new StackLayout { Spacing = 0, Orientation = StackOrientation.Horizontal };
StepDisplay.Children.Add(Step);
StepDisplay.Children.Add(Description);
JitPageStackView.Children.Add(StepDisplay);
答案 0 :(得分:0)
在C#版本中,您将填充设置为pkg-config --libs gtk+-2.0
“说明” ,而不是StackLayout
更改此设置,它应该作为XAML版本
Frame
希望这会有所帮助。-