本文整理汇总了C#中Xamarin.Forms.ToolbarItem.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# ToolbarItem.SetBinding方法的具体用法?C# ToolbarItem.SetBinding怎么用?C# ToolbarItem.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xamarin.Forms.ToolbarItem
的用法示例。
在下文中一共展示了ToolbarItem.SetBinding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnBindingContextChanged
protected override void OnBindingContextChanged ()
{
base.OnBindingContextChanged ();
if (BindingContext == null)
return;
if ((BindingContext as MapCardViewModel).Context != MapCardViewModel.MapCardContext.Search) {
var doneButton = new ToolbarItem ();
doneButton.SetBinding<MapCardViewModel> (ToolbarItem.TextProperty, vm => vm.DoneLabel);
doneButton.SetBinding<MapCardViewModel> (ToolbarItem.CommandProperty, vm => vm.DoneCommand);
ToolbarItems.Add (doneButton);
}
}
示例2: CreateClearButton
ToolbarItem CreateClearButton ()
{
var clearButton = new ToolbarItem { Name = "Clear" };
clearButton.SetBinding (ToolbarItem.CommandProperty, "ClearTrackFilters");
return clearButton;
}
示例3: OnBindingContextChanged
protected override void OnBindingContextChanged()
{
base.OnBindingContextChanged();
// Fixed in next version of Xamarin.Forms. BindingContext is not properly set on ToolbarItem.
var aboutItem = new ToolbarItem { Name = "About", BindingContext = BindingContext };
aboutItem.SetBinding(ToolbarItem.CommandProperty, new Binding("ShowAboutPageCommand"));
ToolbarItems.Add(aboutItem);
}
示例4: CreateFiltersItem
static ToolbarItem CreateFiltersItem ()
{
var filters = new ToolbarItem {
Icon = "filter.png",
Name = "Filter"
};
filters.SetBinding (ToolbarItem.CommandProperty, "ShowFilters");
return filters;
}
示例5: FruitsPage
public FruitsPage()
{
var toolbarItem = new ToolbarItem
{
Text = "Add fruit",
};
toolbarItem.SetBinding(ToolbarItem.CommandProperty, FruitsViewModel.AddFruitCommandProperty);
ToolbarItems.Add(toolbarItem);
Content = FruitsListView();
}
示例6: NewEntryPage
public NewEntryPage ()
{
Title = "New Entry";
// Form fields
var title = new EntryCell { Label = "Titel" };
title.SetBinding (EntryCell.TextProperty, "Title", BindingMode.TwoWay);
var latitude = new EntryCell { Label = "Latitude", Keyboard = Keyboard.Numeric };
latitude.SetBinding (EntryCell.TextProperty, "Latitude", BindingMode.TwoWay);
var longitude = new EntryCell {Label = "Longitude", Keyboard = Keyboard.Numeric };
longitude.SetBinding (EntryCell.TextProperty, "Longitude", BindingMode.TwoWay);
var date = new DatePickerEntryCell {Label = "Date"};
date.SetBinding (DatePickerEntryCell.DateProperty,
"Date",BindingMode.TwoWay);
var rating = new EntryCell { Label = "Rating", Keyboard = Keyboard.Numeric };
rating.SetBinding (EntryCell.TextProperty, "Rating", BindingMode.TwoWay);
var notes = new EntryCell { Label = "Notes" };
notes.SetBinding (EntryCell.TextProperty, "Notes", BindingMode.TwoWay);
// Form
var entryForm = new TableView {
Intent = TableIntent.Form,
Root = new TableRoot {
new TableSection () {
title,
latitude,
longitude,
date,
rating,
notes
}
}
};
Content = entryForm;
var save = new ToolbarItem {
Text = "Save"
};
save.SetBinding (ToolbarItem.CommandProperty, "SaveCommand");
ToolbarItems.Add (save);
}
示例7: ContactsView
public ContactsView ()
{
BaseViewModel.CreateAndBind<ContactsViewModel> (this);
SetBinding (ContactsView.NavigationProperty, new Binding("Navigation"));
SetBinding(AlertProperty, new Binding("AlertMessage"));
Title = "Contacts";
NavigationPage.SetBackButtonTitle (this, "");
var addContactButton = new ToolbarItem
{
Icon = "plus.png",
Name = "Add Contact",
};
addContactButton.SetBinding<ContactsViewModel> (ToolbarItem.CommandProperty, vm => vm.AddContactCommand);
this.ToolbarItems.Add(addContactButton);
var relativeLayout = new RelativeLayout
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand
};
var searchBar = CreateSearchBar ();
relativeLayout.Children.Add (searchBar,
Constraint.RelativeToParent ((parent) => { return parent.X; }),
Constraint.RelativeToParent ((parent) => { return parent.Y; }),
Constraint.RelativeToParent ((parent) => { return parent.Width; })
);
_listView = CreateList ();
relativeLayout.Children.Add (_listView,
Constraint.RelativeToParent ((parent) => { return parent.X; }),
Constraint.RelativeToView (searchBar, (parent,sibling) => { return sibling.Height; }),
Constraint.RelativeToParent ((parent) => { return parent.Width; }),
Constraint.RelativeToView (searchBar, (parent,sibling) => { return parent.Height - sibling.Height; })
);
var gettingStarted = CreateGettingStartedView ();
relativeLayout.Children.Add (gettingStarted,
Constraint.RelativeToParent ((parent) => { return parent.X; }),
Constraint.RelativeToParent ((parent) => { return (parent.Height / 2) - 100; }),
Constraint.RelativeToParent ((parent) => { return parent.Width; }),
Constraint.RelativeToParent ((parent) => { return parent.Height - 175; })
);
Content = relativeLayout;
}
示例8: MainPage
public MainPage ()
{
Title = "TripLog";
var itemTemplate = new DataTemplate (typeof(TextCell));
itemTemplate.SetBinding (TextCell.TextProperty, "Title");
itemTemplate.SetBinding (TextCell.DetailProperty, "Notes");
var entries = new ListView {
ItemTemplate = itemTemplate
};
entries.SetBinding (ListView.ItemsSourceProperty, "LogEntries");
entries.SetBinding (ListView.IsVisibleProperty, "IsBusy", converter: new ReverseBooleanConverter());
entries.ItemTapped += (sender, e) =>
{
var item = (TripLogEntry) e.Item;
vm.ViewCommand.Execute (item);
};
var newButton = new ToolbarItem { Text = "New" };
newButton.SetBinding (ToolbarItem.CommandProperty, "NewCommand");
ToolbarItems.Add (newButton);
var loading = new StackLayout {
Orientation = StackOrientation.Vertical,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
Children = {
new ActivityIndicator {
IsRunning = true
},
new Label {
Text = "Loading Entries..."
}
}
};
loading.SetBinding (StackLayout.IsVisibleProperty, "IsBusy");
var mainLayout = new Grid {
Children = {
entries,
loading
}
};
Content = mainLayout;
}
示例9: ProfileView
public ProfileView ()
{
BaseViewModel.CreateAndBind<ProfileViewModel> (this);
SetBinding (ProfileView.NavigationProperty, new Binding("Navigation"));
Title = "Profile";
NavigationPage.SetBackButtonTitle (this, "");
var edit = new ToolbarItem ();
edit.Name = "Edit";
edit.SetBinding<ProfileViewModel> (ToolbarItem.CommandProperty, vm => vm.EditProfileCommand);
this.ToolbarItems.Add(edit);
Content = CreateStack ();
}
示例10: RateSessionView
/* * * * * * * * * * * * * * * * */
public RateSessionView (string sessionId)
{
BaseViewModel.CreateAndBind<RateSessionViewModel> (this, sessionId);
Title = "Rate Session";
NavigationPage.SetBackButtonTitle (this, "");
SetBinding (NavigationProperty, new Binding ("Navigation"));
var doneButton = new ToolbarItem { Name = "Done" };
doneButton.SetBinding (ToolbarItem.CommandProperty, "SaveRating");
this.ToolbarItems.Add(doneButton);
SetBinding (AlertProperty, new Binding("AlertMessage"));
Content = CreateStack ();
}
示例11: SplashscreenPage
public SplashscreenPage()
{
Title = "";
Content = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
Children =
{
new SquawkLabel
{
Text = "Connecting...",
HorizontalOptions = LayoutOptions.CenterAndExpand,
FontSize = 24,
},
new ActivityIndicator
{
IsRunning = true,
}
}
};
//NOTE: this button is a workaround, adding button on HomePage doesn't work so it will be presented always
//but will work only in Chat
var sendImageItem = new ToolbarItem("send photo", Device.OnPlatform(null, null, "appbar.image.beach.png"),
() =>
{
var homeVm = ViewModelBase.CurrentViewModel as HomeViewModel;
if (homeVm != null)
{
//homeVm.SendImageCommand.Execute(null);
}
else if (ViewModelBase.CurrentViewModel != null)
{
ViewModelBase.CurrentViewModel.Notify(";(", "You can send images only in chat. I just don't know how to show it only on specific pages - ToolbarItems.Add doesn't work on HomePage ;(");
}
});
sendImageItem.SetBinding(ToolbarItem.CommandProperty, new Binding("SendImageCommand"));
Device.OnPlatform(WinPhone: () => ToolbarItems.Add(sendImageItem));
// Accomodate iPhone status bar.
this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
}
示例12: EditProfileView
// public string Success {
// get {
// return (string)GetValue (SuccessProperty);
// }
// set {
// SetValue (SuccessProperty, value);
// }
// }
//
// public static readonly BindableProperty SuccessProperty =
// BindableProperty.Create<EditProfileView, string>(b => b.Success, null,
// propertyChanged: async (bindable, oldValue, newValue) => {
// if(newValue == null)
// return;
// var view = (EditProfileView)bindable;
// await view.DisplayAlert ("Success", newValue, null, "Okay");
// ((EditProfileViewModel)view.BindingContext).SuccessMessage = null;
// });
public EditProfileView ()
{
BaseViewModel.CreateAndBind<EditProfileViewModel> (this);
SetBinding (EditProfileView.NavigationProperty, new Binding("Navigation"));
SetBinding(AlertProperty, new Binding("AlertMessage"));
// SetBinding(SuccessProperty, new Binding("SuccessMessage"));
Title = "Profile";
NavigationPage.SetBackButtonTitle (this, "");
var save = new ToolbarItem ();
save.Name = "Save";
save.SetBinding<EditProfileViewModel> (ToolbarItem.CommandProperty, vm => vm.SaveProfileCommand);
this.ToolbarItems.Add(save);
Content = CreateStack ();
}
示例13: AddReviewView
public AddReviewView ()
{
viewModel = new AddReviewsViewModel (Navigation);
BindingContext = viewModel;
Title = "Add New Review";
var email = new Entry () { Placeholder = "Email Address" };
email.SetBinding (Entry.TextProperty, "Email");
var cheeseType = new Entry () { Placeholder = "Cheese Type" };
cheeseType.SetBinding (Entry.TextProperty, "CheeseType");
var dairy = new Entry () { Placeholder = "Dairy" };
dairy.SetBinding (Entry.TextProperty, "DairyName");
var comments = new Editor ();
comments.BackgroundColor = Color.FromRgb (255, 255, 229);
comments.VerticalOptions = LayoutOptions.FillAndExpand;
comments.SetBinding (Editor.TextProperty, "Comments");
var saveButton = new ToolbarItem () { Text = "Save" };
saveButton.SetBinding (ToolbarItem.CommandProperty, "AddCommand");
ToolbarItems.Add (saveButton);
Content = new StackLayout {
Padding= new Thickness(10,10,10,10),
Children = {
email,
cheeseType,
dairy,
new Label{ Text = "Comments:" },
comments
}
};
}
示例14: ToDoListPage
public ToDoListPage()
{
BindingContext = new ToDoListViewModel();
var listView = new ListView();
listView.ItemTemplate = new DataTemplate(typeof(TextCell));
// Bindings para los items de la vista
listView.SetBinding(ListView.ItemsSourceProperty, "ToDoItems");
listView.SetBinding(ListView.SelectedItemProperty, "SelectedToDoItem");
listView.ItemSelected += (s, a) =>
{
(BindingContext as ToDoListViewModel).ViewDetailCommand.Execute(null);
};
// Binding para los items de la lista
BindingContext = new ToDoListViewModel();
// 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" };
saveButton.SetBinding(ToolbarItem.CommandProperty, "SaveToDosCommand");
var addButton = new ToolbarItem { Text = "Add" };
addButton.SetBinding(ToolbarItem.CommandProperty, "AddToDoCommad");
Content = new StackLayout {
Children = {
listView
}
};
ToolbarItems.Add(saveButton);
ToolbarItems.Add(addButton);
}
示例15: Init
private void Init()
{
var addTile = new ToolbarItem
{
Text = "Add",
Icon = OnPlatform(
iOS: (FileImageSource)FileImageSource.FromFile("Icons/Done.png"),
Android: (FileImageSource)FileImageSource.FromFile("Done.png"),
Windows: (FileImageSource)FileImageSource.FromFile("Assets/Icons/Done.png"))
};
addTile.SetBinding(ToolbarItem.CommandProperty, new Binding("AddTileCommand"));
ToolbarItems.Add(addTile);
var removeTile = new ToolbarItem
{
Text = "Remove",
Icon = OnPlatform(
iOS: (FileImageSource)FileImageSource.FromFile("Icons/Remove.png"),
Android: (FileImageSource)FileImageSource.FromFile("Remove.png"),
Windows: (FileImageSource)FileImageSource.FromFile("Assets/Icons/Remove.png"))
};
removeTile.SetBinding(ToolbarItem.CommandProperty, new Binding("RemoveTileCommand"));
ToolbarItems.Add(removeTile);
}