轻轻地,我怎样才能在xaml中实现这一点?它一定很容易,但不能把它包裹起来:/ 这就是我想要实现的目标:
这是我的view.xaml
<StackLayout x:Name="stackExample">
<StackLayout Margin="10,10,10,5" >
<Label Text="Info" />
<BoxView Color="#29abe2" WidthRequest ="100" HeightRequest="1" />
</StackLayout>
<StackLayout x:Name="optionsContentStack" >
</StackLayout>
</StackLayout>
这是我的view.xaml.cs
foreach (var ex in example)
{
var labelHtmlInst = new Label { Text = ex.Info, FontSize = 15, TextColor = Color.FromHex("#222222"), HorizontalOptions = LayoutOptions.Center, VerticalOptions=LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Start };
optionsContentStack.Children.Add(labelHtmlInst);
var labelDs = new Label { Text = ex.Info, FontSize = 10, TextColor = Color.FromHex("#999999"), HorizontalOptions=LayoutOptions.Start, HorizontalTextAlignment = TextAlignment.Start, Margin = new Thickness(0, 0, 0, 10) };
optionsContentStack.Children.Add(labelDs);
var boxviewDs = new BoxView { Color = Color.FromHex("#f7931e"), WidthRequest = 100, HeightRequest = 1, HorizontalOptions = LayoutOptions.Start };
optionsContentStack.Children.Add(boxviewDs);
}