0
如何在其他单元格中添加按钮? 我试图做到这一点,但没有工作。感谢帮助。我的鳕鱼:其他单元格中的按钮:Xamarin.Forms
var button = new Image { Source = "page.png"};
button.GestureRecognizers.Add(new TapGestureRecognizer
{
Command = new Command((async sender =>
{
await Navigation.PushAsync(new page());
}))
});
var grid = new Grid();
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = 200 });
grid.Children.Add(new Label { Text = "00"}, 0, 0);
grid.Children.Add(new Label { Text = "01"}, 0, 1);
grid.Children.Add(new Label { Text = "02"}, 0, 2);
grid.Children.Add(button, 1, 0); //this is not visible
grid.Children.Add(button, 1, 1); //this is not visible
grid.Children.Add(button, 1, 2);
grid.Children.Add(new Label { Text = "20"}, 2, 0);
grid.Children.Add(new Label { Text = "21"}, 2, 1);
grid.Children.Add(new Label { Text = "22"}, 2, 2);
您不能在多个单元中使用同一个控件实例。您需要为每个希望显示的单元格创建一个新实例。 – Jason
如何做到这一点? – user5734658