你需要一個像沒有任何其他選項,添加加號,而無需使用工具欄項目在主詳細頁面
繼創建頁面是一些示例代碼
public class TodoListPageCS : ContentPage
{
private ToolbarItem _saveAddToolBarItem;
public TodoListPageCS()
{
Title = "Page Name";
_saveAddToolBarItem = new ToolbarItem()
{ Text = "Save"};
ToolbarItems.Add(_saveAddToolBarItem);
_saveAddToolBarItem.Clicked += _saveAddToolBarItem_Clicked;
Content = new StackLayout {
Children = {
new Label {
Text = "Todo list data goes here",
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.CenterAndExpand
}
}
};
}
private void _saveAddToolBarItem_Clicked(object sender, System.EventArgs e)
{
throw new System.NotImplementedException();
}
}
否則,你需要創建自己的定製基頁,而不是內容頁
要改變工具欄的顏色參考以下鏈接: https://forums.xamarin.com/discussion/44586/navigationbar-background-image-renderer-android
跳這個代碼將有助於你
計算策略,以更改工具欄顏色:
Detail = new NavigationPage((Page)Activator.CreateInstance(item.TargetType)) {
BarBackgroundColor = Color.FromHex("#42a990"),
BarTextColor = Color.White,
};
您需要創建工具欄_saveAddToolBarIte m = new ToolbarItem() {Icon = Constants.ASSES_PLUS_ICON,}; _saveAddToolBarItem.Clicked + = _saveAddImage_Clicked; – sumeet
我不想添加工具欄項。我改變了問題,添加圖像,讓你可以瞭解我想要的 –
沒有任何其他選項,你需要使用工具欄添加加號圖標 – sumeet