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