2016-09-22 10 views
0

のボタン(これはTabbedPageで一枚のカードの一部です):助けをXamarin.Forms:このコード上の他のページにボタンを追加する方法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
Is i understood your issue right, you just need button in another tab? 

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

})); 
+0

OKが、どのように透明に所望の画像と背景色をボタンとして、ボタンの – user5734658

+0

だけで設定Imageプロパティを画像を追加するタップジェスチャー認識を使用することができます。編集内容を参照 – Greensy

+0

最初のコードは機能していません/ ImageSource.FromFileはxamarin.formsの暗黙にすることはできません – user5734658

関連する問題