0

How to add button to other page on this code (this is part of one card in 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"  
                    }
             }
            }
        });

Thanks for help.

4

1 回答 1

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 => {

}));
于 2016-09-22T16:04:10.523 回答