如何在此代码上向其他页面添加按钮(这是TabbedPage中一张卡片的一部分):
this.Children.Add(new ContentPage
{
Title = "Text",
Content = new StackLayout
{
Padding = 20,
VerticalOptions = LayoutOptions.FillAndExpand,
Children =
{
new Image
{
Source = ImageSource.FromFile("image.png")
},
new Label
{
TextColor = Color.FromHex("#5F5A5A"),
FontSize = 16,
Text = "Other text"
}
}
}
});
感谢您的帮助。
答案 0 :(得分:0)
如果我理解你的问题,你只需要另一个标签中的按钮?
this.Children.Add(new ContentPage
{
Title = "Text",
Content = new StackLayout
{
Padding = 20,
VerticalOptions = LayoutOptions.FillAndExpand,
Children =
{
new Image
{
Source = ImageSource.FromFile("image.png")
},
new Label
{
TextColor = Color.FromHex("#5F5A5A"),
FontSize = 16,
Text = "Other text"
}
}
}
});
this.Children.Add(new ContentPage
{
Title = "Button",
Content = new StackLayout
{
Children ={
new Button{
Image = ImageSource.FromFile("button.png"),
Backgroundcolor = "Transparent"
}
}
}
});
或者,您可以使用点击手势识别器
var button = new Image { };
button.GestureRecognizers.Add (new TapGestureRecognizer (sender => {
}));