本文整理汇总了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);
}
示例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);
};
}
}
示例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);
}
示例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;
};
}
示例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
}
};
}
示例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;
}
示例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 ();
}
示例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);
}
示例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;
}
示例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);
// }
}
示例11: OnAppearing
protected override void OnAppearing()
{
base.OnAppearing();
ToolbarItems.Add(toolbarItem = new ToolbarItem("Save", null, Save(), 0, 0));
vm.OnAppearing();
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}