當前位置: 首頁>>代碼示例>>C#>>正文


C# Forms.ToolbarItem類代碼示例

本文整理匯總了C#中Xamarin.Forms.ToolbarItem的典型用法代碼示例。如果您正苦於以下問題:C# ToolbarItem類的具體用法?C# ToolbarItem怎麽用?C# ToolbarItem使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ToolbarItem類屬於Xamarin.Forms命名空間,在下文中一共展示了ToolbarItem類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ToDoListPage

        public ToDoListPage()
        {
            BindingContext = new ToDoListViewModel();

            var listView = new ListView();
            listView.ItemTemplate = new DataTemplate(typeof(TextCell));

            // Bindings para los items de la lista
            listView.SetBinding(ListView.ItemsSourceProperty, "ToDoItems");
            listView.SetBinding(ListView.SelectedItemProperty, "SelectedToDoItem");

            // Bindings para definir la información que se muestra por cada fila
            listView.ItemTemplate.SetBinding(TextCell.TextProperty, "Name");
            listView.ItemTemplate.SetBinding(TextCell.DetailProperty, "Description");

            var saveButton = new ToolbarItem { Text = "Save" };

            var addButton = new ToolbarItem { Text = "Add" };

            Content = new StackLayout {
                Children = {
                    listView
                }
            };

            ToolbarItems.Add(saveButton);
            ToolbarItems.Add(addButton);
        }
開發者ID:fferegrino,項目名稱:mvvm,代碼行數:28,代碼來源:ToDoListPage.cs

示例2: GetToolbarItem

		public void GetToolbarItem(ToolbarItem tbi, Android.Views.View view){
			int res = 0;
			int imgRes = 0;
			if (tbi.Icon == null) {
				if (tbi.Priority == 0)
					res = Resource.Id.btn_textLeft;
				else
					res = Resource.Id.btn_textRight;
				var btn = (Android.Widget.Button)view.FindViewById(res);
				btn.Text = "  " + tbi.Text;
				btn.TextSize =  (float)Device.GetNamedSize (NamedSize.Small, typeof(Label));
				btn.Visibility = Android.Views.ViewStates.Visible;
				btn.SetTextColor(Color.FromHex("218DFF").ToAndroid ());
				btn.Click +=  (sender, ee) => { 
					if (tbi.Command != null)
						tbi.Command.Execute(tbi.CommandParameter);
				};
			} else {
				if (tbi.Priority == 0)
					res = Resource.Id.btn_imageLeft;
				else
					res = Resource.Id.btn_imageRight;

				imgRes = Resources.GetIdentifier(tbi.Icon.File.Split('.')[0], "drawable", MainActivity.Activity.PackageName);
				var imBtn = (Android.Widget.ImageButton)view.FindViewById(res);
				imBtn.SetImageResource(imgRes);
				imBtn.Visibility = Android.Views.ViewStates.Visible;
				imBtn.Click +=  (sender, ee) => { 
					if (tbi.Command != null)
						tbi.Command.Execute(tbi.CommandParameter);
				};
			}
		}
開發者ID:luis-villase,項目名稱:MxApp,代碼行數:33,代碼來源:NavigationPageRenderer.cs

示例3: TodoListPage

		public TodoListPage ()
		{
			Title = AppResources.ApplicationTitle; // "Todo";

			listView = new ListView { RowHeight = 40 };
			listView.ItemTemplate = new DataTemplate (typeof (TodoItemCell));

			listView.ItemSelected += (sender, e) => {
				var todoItem = (TodoItem)e.SelectedItem;

				// use C# localization
				var todoPage = new TodoItemPage();

				// use XAML localization
//				var todoPage = new TodoItemXaml();


				todoPage.BindingContext = todoItem;
				Navigation.PushAsync(todoPage);
			};

			var layout = new StackLayout();
			if (Device.OS == TargetPlatform.WinPhone) { // WinPhone doesn't have the title showing
				layout.Children.Add(new Label{Text="Todo", Font=Font.SystemFontOfSize(NamedSize.Large, FontAttributes.Bold)});
			}
			layout.Children.Add(listView);
			layout.VerticalOptions = LayoutOptions.FillAndExpand;
			Content = layout;


			var tbiAdd = new ToolbarItem("Add", "plus.png", () =>
				{
					var todoItem = new TodoItem();
					var todoPage = new TodoItemPage();
					todoPage.BindingContext = todoItem;
					Navigation.PushAsync(todoPage);
				}, 0, 0);


			ToolbarItems.Add (tbiAdd);


			var tbiSpeak = new ToolbarItem ("Speak", "chat.png", () => {
				var todos = App.Database.GetItemsNotDone();
				var tospeak = "";
				foreach (var t in todos)
					tospeak += t.Name + " ";
				if (tospeak == "") tospeak = "there are no tasks to do";

				if (todos.Any ()) {
					var s = L10n.Localize ("SpeakTaskCount", "Number of tasks to do");
					tospeak = String.Format (s, todos.Count ()) + tospeak;
				}

				DependencyService.Get<ITextToSpeech>().Speak(tospeak);
			}, 0, 0);
			ToolbarItems.Add (tbiSpeak);


		}
開發者ID:ZaK14120,項目名稱:xamarin-forms-samples,代碼行數:60,代碼來源:TodoListPage.cs

示例4: TweetImagePage

        public TweetImagePage(string image)
        {
            InitializeComponent();
            var item = new ToolbarItem
            {
                Text = "Done",
                Command = new Command(async () => await Navigation.PopModalAsync())
            };
            if (Device.OS == TargetPlatform.Android)
                item.Icon = "toolbar_close.png";
            ToolbarItems.Add(item);

            try
            {
                MainImage.Source = new UriImageSource
                {
                    Uri = new Uri(image),
                    CachingEnabled = true,
                    CacheValidity = TimeSpan.FromDays(3)
                };
            }
            catch(Exception ex)
            {
                Debug.WriteLine("Unable to convert image to URI: " + ex);
                DependencyService.Get<IToast>().SendToast("Unable to load image.");
            }

            MainImage.PropertyChanged += (sender, e) =>
                {
                    if(e.PropertyName != nameof(MainImage.IsLoading))
                        return;
                    ProgressBar.IsRunning = MainImage.IsLoading;
                    ProgressBar.IsVisible = MainImage.IsLoading;
                };
        }
開發者ID:RobGibbens,項目名稱:app-evolve,代碼行數:35,代碼來源:TweetImagePage.xaml.cs

示例5: LoginPageCS

		public LoginPageCS ()
		{
			var toolbarItem = new ToolbarItem {
				Text = "Sign Up"
			};
			toolbarItem.Clicked += OnSignUpButtonClicked;
			ToolbarItems.Add (toolbarItem);

			messageLabel = new Label ();
			usernameEntry = new Entry {
				Placeholder = "username"	
			};
			passwordEntry = new Entry {
				IsPassword = true
			};
			var loginButton = new Button {
				Text = "Login"
			};
			loginButton.Clicked += OnLoginButtonClicked;

			Title = "Login";
			Content = new StackLayout { 
				VerticalOptions = LayoutOptions.StartAndExpand,
				Children = {
					new Label { Text = "Username" },
					usernameEntry,
					new Label { Text = "Password" },
					passwordEntry,
					loginButton,
					messageLabel
				}
			};
		}
開發者ID:ChandrakanthBCK,項目名稱:xamarin-forms-samples,代碼行數:33,代碼來源:LoginPageCS.cs

示例6: Schedules

		public Schedules (string title)
		{
			ToolbarItem itemPrint = new ToolbarItem {
				Text = "Printable web version",
				Order = ToolbarItemOrder.Secondary,

			};
			ToolbarItems.Add(itemPrint);
			var browser = new BaseUrlWebView (); // temporarily use this so we can custom-render in iOS
			Title=title;
			var htmlSource = new HtmlWebViewSource ();
			htmlSource.BaseUrl = DependencyService.Get<IBaseUrl> ().Get ();
			string filename = "";
			if (title == "Table of study schedules")
				filename = "schedule1.html";
			else if (title == "勉強スケジュールの比較")
				filename = "schedule2.html";
			else if (title == "100-minute lessons")
				filename = "schedule6.html";
			else if (title == "90-minute lessons")
				filename = "schedule5.html";
			else if (title == "80-minute lessons")
				filename = "schedule4.html";
			else if (title == "60-minute lessons")
				filename = "schedule3.html";
			
			if (Device.OS != TargetPlatform.iOS) {
				browser.Source = htmlSource.BaseUrl+filename;
			}
			else
			{	      
				browser.Source = htmlSource.BaseUrl + "/" + filename;
			}
			Content = browser;
		}
開發者ID:kimuraeiji214,項目名稱:Keys,代碼行數:35,代碼來源:Schedules.cs

示例7: AccionesDia

		public AccionesDia (MasterDetailPage masterDetail, int tdia, Usuario tusuario)
		{
			usuario = tusuario;
			dia = tdia;

			var guardaritem = new ToolbarItem {
				Text = "Guardar"
			};
			guardaritem.Clicked += (object sender, System.EventArgs e) => 
			{
				guardarAcciones();
			};

			ToolbarItems.Add(guardaritem);
			this.Title = "Acciones ahorradoras";

			master = masterDetail;




			//End Dias


			cargarAcciones ();




		}
開發者ID:jupabequi,項目名稱:COLPLATP12,代碼行數:30,代碼來源:AccionesDia.xaml.cs

示例8: InitializeToolBars

        private void InitializeToolBars()
        {
            string addIcon = null;
            string refreshIcon = null;

            if (Device.OS == TargetPlatform.WinPhone)
            {
                addIcon = "Toolkit.Content/ApplicationBar.Add.png";
                refreshIcon = "Toolkit.Content/ApplicationBar.Refresh.png";
            }
            var addToolButton = new ToolbarItem("Add", addIcon, () =>
            {
                var todoItem = new ToDoItem();
                var todoPage = new ToDoItemXaml();
                todoPage.BindingContext = todoItem;
                Navigation.PushAsync(todoPage);
            }, 0, 0);

            var refreshToolButton = new ToolbarItem("Refresh", refreshIcon, () =>
            {
                OnAppearing();

            }, 0, 0);

            ToolbarItems.Add(addToolButton);
            ToolbarItems.Add(refreshToolButton);
        }
開發者ID:fellipetenorio,項目名稱:mobile-services-samples,代碼行數:27,代碼來源:ToDoListXaml.xaml.cs

示例9: ToolbarBtn

        public static ToolbarItem[] ToolbarBtn()
        {
            var MenuBtn = new ToolbarItem("منوی اصلی", "Menu.png", () =>
            {
                if (!HomePage.MasterPage.IsVisible)
                {
                    HomePage.MasterPage.IsVisible = true;
                    FirstPage.menuPage.Menu.SelectedItem = null;
                    FirstPage.menuPage.SpecialMenu.SelectedItem = null;
                    HomePage.doSmoothOpen();
                }

                else
                    HomePage.doSmoothClose();
            });

            toolbarItems[0] = MenuBtn;

            var ShortCut = new ToolbarItem("میانبر", "Shortcut.png", () =>
            {
                if (!HomePage.ShortCutPage.IsVisible)
                {
                    HomePage.doShortcutSmoothOpen();
                    HomePage.ShortCutPage.IsVisible = true;
                    FirstPage.menuPage.ShortcutMenu.SelectedItem = null;
                }

                else
                    HomePage.doShortcutSmoothClose();
            });

            toolbarItems[1] = ShortCut;

            return toolbarItems;
        }
開發者ID:mxmaa64,項目名稱:Calender,代碼行數:35,代碼來源:App.cs

示例10: TodoListXaml

		public TodoListXaml ()
		{
			InitializeComponent ();

			var tbi = new ToolbarItem ("+", null, () => {
				var todoItem = new TodoItem();
				var todoPage = new TodoItemXaml();
				todoPage.BindingContext = todoItem;
				Navigation.PushAsync(todoPage);
			}, 0, 0);
			if (Device.OS == TargetPlatform.Android) { // BUG: Android doesn't support the icon being null
				tbi = new ToolbarItem ("+", "plus", () => {
					var todoItem = new TodoItem();
					var todoPage = new TodoItemXaml();
					todoPage.BindingContext = todoItem;
					Navigation.PushAsync(todoPage);
				}, 0, 0);
			}

			ToolbarItems.Add (tbi);

//			if (Device.OS == TargetPlatform.iOS) {
//				var tbi2 = new ToolbarItem ("?", null, () => {
//					var todos = App.Database.GetItemsNotDone();
//					var tospeak = "";
//					foreach (var t in todos)
//						tospeak += t.Name + " ";
//					if (tospeak == "") tospeak = "there are no tasks to do";
//					App.Speech.Speak(tospeak);
//				}, 0, 0);
//				ToolbarItems.Add (tbi2);
//			}
		}
開發者ID:JeffHarms,項目名稱:xamarin-forms-samples-1,代碼行數:33,代碼來源:TodoListXaml.xaml.cs

示例11: OnAppearing

		protected override void OnAppearing()
		{
			base.OnAppearing();
			ToolbarItems.Add(toolbarItem = new ToolbarItem("Save", null, Save(), 0, 0));

			vm.OnAppearing();
		}
開發者ID:rangeogx1923,項目名稱:AndroidWear,代碼行數:7,代碼來源:EditReminderPage.xaml.cs

示例12: setToolBar

		public void setToolBar(){
			/**
			 * TOOLBAR RELATED CODE
			 */
			var data = DataManager.getInstance ();

			ToolbarItem filterTBI;
			ToolbarItem mapTypeTBI;

			filterTBI = new ToolbarItem ("", "", filterMapItems, 0, 0);
			mapTypeTBI = new ToolbarItem ("", "", changeMap, 0, 0);

			filterTBI.Icon = "Filter.png";
			mapTypeTBI.Icon = "MapChange.png";

			//Change map type
			ToolbarItems.Add (mapTypeTBI);

			if (data.isNetworked()) {
				ToolbarItem refreshTBI;			
				refreshTBI = new ToolbarItem ("", "", refreshData, 0, 0);
				refreshTBI.Icon = "Refresh.png";
				ToolbarItems.Add (refreshTBI);
			}

			ToolbarItems.Add (filterTBI);


		}
開發者ID:r0345,項目名稱:EIMA,代碼行數:29,代碼來源:MapPage.cs

示例13: GroupMatchView

        public GroupMatchView()
        {
            BindingContext = new GroupMatchesViewModel();

            var activity = new ActivityIndicator
            {
                Color = Helpers.Color.Greenish.ToFormsColor(),
                IsEnabled = true
            };
            activity.SetBinding(ActivityIndicator.IsVisibleProperty, "IsBusy");
            activity.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy");

            this.Groups = new ObservableCollection<GroupHelper>();
            var refresh = new ToolbarItem
            {
                Command = ViewModel.LoadItemsCommand,
                Icon = "refresh.png",
                Name = "refresh",
                Priority = 0
            };
            ToolbarItems.Add(refresh);

            ViewModel.ItemsLoaded += new EventHandler((sender, e) =>
            {
                this.Groups.Clear();
                ViewModel.Result.Select(r => r.MatchDate).Distinct().ToList()
                    .ForEach(r => Groups.Add(new GroupHelper(r)));
                foreach (var g in Groups)
                {
                    foreach (var match in ViewModel.Result.Where(m=> m.MatchDate == g.Date))
                    {
                        g.Add(match);
                    }
                }
            });

            Title = "Group Match Schedule";
            var stack = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Padding = new Thickness(0, 0, 0, 8)
            };

            var listView = new ListView
            {
                IsGroupingEnabled = true,
                GroupDisplayBinding = new Binding("Date"),
            };

            var viewTemplate = new DataTemplate(typeof(ScoreCell));

            listView.ItemTemplate = viewTemplate;

            listView.ItemsSource = Groups;
            stack.Children.Add(activity);

            stack.Children.Add(listView);

            Content = stack;
        }
開發者ID:AjourMedia,項目名稱:FootballTournament2014,代碼行數:60,代碼來源:GroupMatchView.cs

示例14: evaluacion

		public evaluacion (MasterDetailPage masterDetail, Usuario tusuario)
		{
			master = masterDetail;
			usuario = tusuario;

			var guardaritem = new ToolbarItem {
				Text = "Guardar"
			};
			guardaritem.Clicked += (object sender, System.EventArgs e) => 
			{
				guardarEvaluacion();
			};

			//ToolbarItems.Add(new ToolbarItem(){Icon="pazosicon.png"});
			ToolbarItems.Add(guardaritem);
			this.Title = "Evaluación del día";




			DateTime fecha = DateTime.Now;
			int dia = (int)fecha.DayOfWeek;
			if (dia == 0) {
				dia = 7;
			}
			diaselected= dia;
			dibuja (dia);

		}
開發者ID:jupabequi,項目名稱:COLPLATP12,代碼行數:29,代碼來源:evaluacion.xaml.cs

示例15: TodoListPage

        public TodoListPage()
        {
            Title = "You do";

            listView = new ListView();
            listView.ItemTemplate = new DataTemplate(typeof(ToDoItemCell));
            listView.ItemSelected += (sender, e) =>
            {
                var todoItem = (TodoItem)e.SelectedItem;
                var todoPage = new TodoItemPage();
                todoPage.BindingContext = todoItem;

                Navigation.PushAsync(todoPage);
            };

            var layout = new StackLayout();
            layout.Children.Add(listView);
            layout.VerticalOptions = LayoutOptions.FillAndExpand;
            Content = layout;

            ToolbarItem tbi = null;
            if (Device.OS == TargetPlatform.Android)
            {
                tbi = new ToolbarItem("+", "plus", () =>{
                    var todoItem = new TodoItem();
                    var todoPage = new TodoItemPage();
                    todoPage.BindingContext = todoItem;
                    Navigation.PushAsync(todoPage);
                },0,0);

            }

            ToolbarItems.Add(tbi);
        }
開發者ID:SindhoojaMullapudi,項目名稱:UDo,代碼行數:34,代碼來源:TodoListPage.cs


注:本文中的Xamarin.Forms.ToolbarItem類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。