public void CreateEventMemberAttachTest() { bool isInvoked = false; var source = new BindingSourceModel(); IEventListener listener = new EventListenerMock(); const string path = "path"; var property = AttachedBindingMember.CreateEvent(path, (info, o, arg3) => null, (model, args) => { model.ShouldEqual(source); args.ShouldNotBeNull(); isInvoked = true; }); property.SetValue(source, new object[] { listener }); isInvoked.ShouldBeTrue(); isInvoked = false; property.SetValue(source, new object[] { null }); isInvoked.ShouldBeFalse(); source = new BindingSourceModel(); property.SetValue(source, new object[] { listener }); isInvoked.ShouldBeTrue(); }
public static void RegisterDialogEntryElementMembers() { var field = typeof(EntryElement).GetField("entry", BindingFlags.NonPublic | BindingFlags.Instance); if (field != null && field.FieldType == typeof(UITextField)) { var getEntryField = ServiceProvider.ReflectionManager.GetMemberGetter <UITextField>(field); TouchBindingErrorProvider.TryGetEntryField = target => { var element = target as EntryElement; if (element != null) { target = getEntryField(element); } return(target); }; } BindingBuilderExtensions.RegisterDefaultBindingMember <EntryElement>(nameof(EntryElement.Value)); var member = MemberProvider.GetBindingMember(typeof(EntryElement), nameof(EntryElement.Changed), true, false); if (member != null) { MemberProvider.Register(AttachedBindingMember.CreateEvent <EntryElement>("ValueChanged", (info, element, arg3) => member.TryObserve(element, arg3))); } }
public static void RegisterStringElementMembers() { BindingBuilderExtensions.RegisterDefaultBindingMember <StringElement>(nameof(StringElement.Value)); MemberProvider.Register(AttachedBindingMember.CreateMember <StringElement, string>(nameof(StringElement.Value), (info, element) => element.Value, (info, element, arg3) => { element.Value = arg3; element.Reload(); })); MemberProvider.Register(AttachedBindingMember.CreateEvent(AttachedMembers.StringElement.TappedEvent, (info, element, arg3) => { var weakWrapper = arg3.ToWeakWrapper(); IDisposable unsubscriber = null; Action action = () => { if (!weakWrapper.EventListener.TryHandle(weakWrapper.EventListener, EventArgs.Empty)) { unsubscriber.Dispose(); } }; unsubscriber = WeakActionToken.Create(element, action, (stringElement, nsAction) => stringElement.Tapped -= nsAction); element.Tapped += action; return(unsubscriber); })); }
public static void RegisterTableViewMembers() { BindingServiceProvider.ResourceResolver.AddType(typeof(UITableViewRowAnimation)); BindingServiceProvider.ResourceResolver.AddType(typeof(UITableViewScrollPosition)); BindingServiceProvider.BindingMemberPriorities[AttachedMembers.UITableView.UseAnimations] = BindingServiceProvider.TemplateMemberPriority + 1; BindingServiceProvider.BindingMemberPriorities[AttachedMembers.UITableView.AddAnimation] = BindingServiceProvider.TemplateMemberPriority + 1; BindingServiceProvider.BindingMemberPriorities[AttachedMembers.UITableView.RemoveAnimation] = BindingServiceProvider.TemplateMemberPriority + 1; BindingServiceProvider.BindingMemberPriorities[AttachedMembers.UITableView.ReplaceAnimation] = BindingServiceProvider.TemplateMemberPriority + 1; BindingServiceProvider.BindingMemberPriorities[AttachedMembers.UITableView.ScrollPosition] = BindingServiceProvider.TemplateMemberPriority + 1; BindingBuilderExtensions.RegisterDefaultBindingMember(AttachedMembers.UIView.ItemsSource.Override <UITableView>()); MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableView.AddAnimation)); MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableView.RemoveAnimation)); MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableView.ReplaceAnimation)); MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableView.ScrollPosition)); MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableView.UseAnimations)); MemberProvider.Register(AttachedBindingMember.CreateEvent(AttachedMembers.UITableView.SelectedItemChangedEvent)); MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UIView.ItemsSource.Override <UITableView>(), TableViewItemsSourceChanged)); MemberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.UITableView.SelectedItem, GetTableViewSelectedItem, SetTableViewSelectedItem, (info, view, arg3) => (IDisposable)view.SetBindingMemberValue(AttachedMembers.UITableView.SelectedItemChangedEvent, arg3))); var itemTemplateMember = AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableView.ItemTemplateSelector, (view, args) => args.NewValue?.Initialize(view)); MemberProvider.Register(itemTemplateMember); MemberProvider.Register(typeof(UITableView), AttachedMemberConstants.ItemTemplate, itemTemplateMember, true); }
private static void RegisterViewMembers(IBindingMemberProvider memberProvider) { //View memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.View.Fragment)); memberProvider.Register(AttachedBindingMember.CreateMember <View, object>(AttachedMemberConstants.FindByNameMethod, ViewFindByNameMember)); memberProvider.Register(AttachedBindingMember.CreateMember <View, object>(AttachedMemberConstants.Parent, GetViewParentValue, SetViewParentValue, ObserveViewParent)); memberProvider.Register(AttachedBindingMember.CreateMember <View, bool>(AttachedMemberConstants.Focused, (info, view) => view.IsFocused, (info, view, arg3) => { if (arg3) { view.RequestFocus(); } else { view.ClearFocus(); } }, "FocusChange")); memberProvider.Register(AttachedBindingMember.CreateMember <View, bool>(AttachedMemberConstants.Enabled, (info, view) => view.Enabled, (info, view, value) => view.Enabled = value)); memberProvider.Register(AttachedBindingMember.CreateMember <View, ViewStates>("Visibility", (info, view) => view.Visibility, (info, view, value) => view.Visibility = value, ObserveViewVisibility)); memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.View.Visible, (info, view) => view.Visibility == ViewStates.Visible, (info, view, value) => view.Visibility = value ? ViewStates.Visible : ViewStates.Gone, ObserveViewVisibility)); memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.View.Hidden, (info, view) => view.Visibility != ViewStates.Visible, (info, view, value) => view.Visibility = value ? ViewStates.Gone : ViewStates.Visible, ObserveViewVisibility)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty <View, object>(AttachedMembers.Toolbar.MenuTemplate.Path)); memberProvider.Register(AttachedBindingMember.CreateEvent <View>("WidthChanged", (info, o, arg3) => new SizeObserver(o, arg3))); memberProvider.Register(AttachedBindingMember.CreateEvent <View>("HeightChanged", (info, o, arg3) => new SizeObserver(o, arg3))); }
private static void RegisterDialogMembers(IBindingMemberProvider memberProvider) { memberProvider.Register(AttachedBindingMember.CreateMember <Element, object>(AttachedMemberConstants.Parent, (info, element) => element.Parent ?? BindingExtensions.AttachedParentMember.GetValue(element, null), (info, element, arg3) => BindingExtensions.AttachedParentMember.SetValue(element, arg3), (info, element, arg3) => BindingExtensions.AttachedParentMember.TryObserve(element, arg3))); IBindingMemberInfo member = memberProvider.GetBindingMember(typeof(EntryElement), "Changed", true, false); if (member != null) { memberProvider.Register(AttachedBindingMember.CreateEvent <EntryElement>("ValueChanged", (info, element, arg3) => member.TryObserve(element, arg3))); } memberProvider.Register(AttachedBindingMember.CreateEvent <StringElement>("Tapped", (info, element, arg3) => { var weakWrapper = arg3.ToWeakWrapper(); IDisposable unsubscriber = null; NSAction action = () => { if (!weakWrapper.EventListener.TryHandle(weakWrapper.EventListener, EventArgs.Empty)) { unsubscriber.Dispose(); } }; unsubscriber = WeakActionToken.Create(element, action, (stringElement, nsAction) => stringElement.Tapped -= nsAction); element.Tapped += action; return(unsubscriber); })); }
public static void RegisterPreferenceMembers() { BindingBuilderExtensions.RegisterDefaultBindingMember(AttachedMembers.Preference.Click); var changeMember = AttachedBindingMember.CreateEvent(AttachedMembers.Preference.ValueChangedEvent); BindingServiceProvider.MemberProvider.Register(changeMember); _valueChangedEventMember = changeMember; }
public static void RegisterTextViewMembers() { BindingBuilderExtensions.RegisterDefaultBindingMember <UITextView>(nameof(UITextView.Text)); NSNotificationCenter.DefaultCenter.AddObserver(UITextView.TextDidChangeNotification, TextDidChangeNotification); var memberInfo = AttachedBindingMember.CreateEvent(AttachedMembers.UITextView.TextChangedEvent, SetTextFieldTextChanged); AttachedBindingMember.TrySetRaiseAction(memberInfo, RaiseTextChanged); MemberProvider.Register(memberInfo); }
public static void RegisterTextFieldMembers() { BindingServiceProvider.ResourceResolver.AddType(typeof(UITextFieldViewMode)); BindingBuilderExtensions.RegisterDefaultBindingMember <UITextField>(nameof(UITextField.Text)); _textObserver = NSNotificationCenter.DefaultCenter.AddObserver(UITextField.TextFieldTextDidChangeNotification, TextDidChangeNotification); var memberInfo = AttachedBindingMember.CreateEvent(AttachedMembers.UITextField.TextChangedEvent, SetTextFieldTextChanged); AttachedBindingMember.TrySetRaiseAction(memberInfo, RaiseTextChanged); MemberProvider.Register(memberInfo); }
private static void RegisterPreferenceMembers(IBindingMemberProvider memberProvider) { BindingBuilderExtensions.RegisterDefaultBindingMember(AttachedMembers.Preference.Click); BindingBuilderExtensions.RegisterDefaultBindingMember <TwoStatePreference>(nameof(TwoStatePreference.Checked)); BindingBuilderExtensions.RegisterDefaultBindingMember <ListPreference>(nameof(ListPreference.Value)); BindingBuilderExtensions.RegisterDefaultBindingMember <MultiSelectListPreference>(nameof(MultiSelectListPreference.Values)); BindingBuilderExtensions.RegisterDefaultBindingMember <EditTextPreference>(nameof(EditTextPreference.Text)); BindingBuilderExtensions.RegisterDefaultBindingMember(AttachedMembers.PreferenceGroup.ItemsSource); var changeMember = AttachedBindingMember.CreateEvent(AttachedMembers.Preference.ValueChangedEvent); BindingServiceProvider.MemberProvider.Register(changeMember); BindingServiceProvider.MemberProvider.Register(typeof(TwoStatePreference), "CheckedChanged", changeMember, true); BindingServiceProvider.MemberProvider.Register(typeof(MultiSelectListPreference), "ValuesChanged", changeMember, true); BindingServiceProvider.MemberProvider.Register(typeof(ListPreference), "EntryChanged", changeMember, true); BindingServiceProvider.MemberProvider.Register(typeof(MultiSelectListPreference), "EntryChanged", changeMember, true); BindingServiceProvider.MemberProvider.Register(typeof(EditTextPreference), "TextChanged", changeMember, true); //ListPreference memberProvider.Register( AttachedBindingMember.CreateMember <ListPreference, IEnumerable <string> >("EntryValues", (info, preference) => preference.GetEntryValues(), (info, preference, arg3) => preference.SetEntryValues(arg3 == null ? Empty.Array <string>() : arg3.ToArray()))); memberProvider.Register( AttachedBindingMember.CreateMember <ListPreference, IEnumerable <string> >("Entries", (info, preference) => preference.GetEntries(), (info, preference, arg3) => preference.SetEntries(arg3 == null ? Empty.Array <string>() : arg3.ToArray()))); //MultiSelectListPreference memberProvider.Register( AttachedBindingMember.CreateMember <MultiSelectListPreference, IEnumerable <string> >("EntryValues", (info, preference) => preference.GetEntryValues(), (info, preference, arg3) => preference.SetEntryValues(arg3 == null ? Empty.Array <string>() : arg3.ToArray()))); memberProvider.Register( AttachedBindingMember.CreateMember <MultiSelectListPreference, IEnumerable <string> >("Entries", (info, preference) => preference.GetEntries(), (info, preference, arg3) => preference.SetEntries(arg3 == null ? Empty.Array <string>() : arg3.ToArray()))); //PreferenceGroup memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.PreferenceGroup.ItemsSource, PreferenceGroupItemsSourceChanged)); var templateMember = AttachedBindingMember.CreateAutoProperty(AttachedMembers.PreferenceGroup.ItemTemplateSelector); memberProvider.Register(templateMember); memberProvider.Register(AttachedMemberConstants.ItemTemplate, templateMember); }
private static void RegisterDialogMembers(IBindingMemberProvider memberProvider) { BindingBuilderExtensions.RegisterDefaultBindingMember <Element>(nameof(Element.Caption)); memberProvider.Register(AttachedBindingMember.CreateMember <Element, string>(nameof(Element.Caption), (info, element) => element.Caption, (info, element, arg3) => { element.Caption = arg3; element.Reload(); })); memberProvider.Register(AttachedBindingMember.CreateMember <Element, object>(AttachedMemberConstants.ParentExplicit, (info, element) => element.Parent, null)); BindingBuilderExtensions.RegisterDefaultBindingMember <EntryElement>(nameof(EntryElement.Value)); IBindingMemberInfo member = memberProvider.GetBindingMember(typeof(EntryElement), nameof(EntryElement.Changed), true, false); if (member != null) { memberProvider.Register(AttachedBindingMember.CreateEvent <EntryElement>("ValueChanged", (info, element, arg3) => member.TryObserve(element, arg3))); } BindingBuilderExtensions.RegisterDefaultBindingMember <StringElement>(nameof(StringElement.Value)); memberProvider.Register(AttachedBindingMember.CreateMember <StringElement, string>(nameof(StringElement.Value), (info, element) => element.Value, (info, element, arg3) => { element.Value = arg3; element.Reload(); })); memberProvider.Register(AttachedBindingMember.CreateEvent(AttachedMembers.StringElement.TappedEvent, (info, element, arg3) => { var weakWrapper = arg3.ToWeakWrapper(); IDisposable unsubscriber = null; Action action = () => { if (!weakWrapper.EventListener.TryHandle(weakWrapper.EventListener, EventArgs.Empty)) { unsubscriber.Dispose(); } }; unsubscriber = WeakActionToken.Create(element, action, (stringElement, nsAction) => stringElement.Tapped -= nsAction); element.Tapped += action; return(unsubscriber); })); }
public static void RegisterActionBarBaseMembers() { MemberProvider.Register(AttachedBindingMember.CreateMember <ActionBar, object>(AttachedMemberConstants.ParentExplicit, (info, bar) => bar.ThemedContext.GetActivity(), null)); MemberProvider.Register(AttachedBindingMember .CreateNotifiableMember <ActionBar, string>(nameof(ActionBar.Subtitle), (info, actionBar) => actionBar.Subtitle, (info, actionBar, value) => { actionBar.Subtitle = value; return(true); })); MemberProvider.Register(AttachedBindingMember .CreateNotifiableMember <ActionBar, string>(nameof(ActionBar.Title), (info, actionBar) => actionBar.Title, (info, actionBar, value) => { actionBar.Title = value; return(true); })); MemberProvider.Register(AttachedBindingMember.CreateMember <ActionBar, HomeButtonImpl>("HomeButton", (info, bar) => HomeButtonImpl.GetOrAdd(bar), null)); MemberProvider.Register(AttachedBindingMember.CreateEvent <HomeButtonImpl>("Click", (info, homeButton, arg3) => homeButton.AddWithUnsubscriber(arg3))); }
public void CreateEventGenericTest() { IEventListener listener = new EventListenerMock(); var source = new BindingSourceModel(); const string path = "path"; var @event = AttachedBindingMember.CreateEvent <BindingSourceModel>(path, (info, o, arg3) => null); @event.Path.ShouldEqual(path); @event.Type.ShouldEqual(typeof(Delegate)); @event.CanRead.ShouldBeTrue(); @event.CanWrite.ShouldBeTrue(); @event.Member.ShouldBeNull(); @event.MemberType.ShouldEqual(BindingMemberType.Event); @event.GetValue(source, null).ShouldBeType <BindingActionValue>(); @event.SetValue(source, new object[] { listener }); var value = (BindingActionValue)@event.GetValue(source, null); value.Member.ShouldEqual(@event); value.MemberSource.Target.ShouldEqual(source); }
public static void RegisterTableViewCellMembers() { BindingBuilderExtensions.RegisterDefaultBindingMember <UITableViewCell>(() => c => c.TextLabel.Text); BindingServiceProvider.ResourceResolver.AddType(typeof(UITableViewCellEditingStyle)); BindingServiceProvider.ResourceResolver.AddType(typeof(UITableViewCellAccessory)); BindingServiceProvider.ResourceResolver.AddType(typeof(UITableViewCellSelectionStyle)); BindingServiceProvider.ResourceResolver.AddType(typeof(UITableViewCellSeparatorStyle)); BindingServiceProvider.ResourceResolver.AddType(typeof(UITableViewCellStyle)); var member = AttachedBindingMember.CreateEvent(AttachedMembers.UITableViewCell.AccessoryButtonTappedEvent); MemberProvider.Register(member); MemberProvider.Register("Click", member); MemberProvider.Register(AttachedBindingMember.CreateEvent(AttachedMembers.UITableViewCell.DeleteClickEvent)); MemberProvider.Register(AttachedBindingMember.CreateEvent(AttachedMembers.UITableViewCell.InsertClickEvent)); MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableViewCell.TitleForDeleteConfirmation)); MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableViewCell.EditingStyle)); BindingServiceProvider.MemberProvider.Register(AttachedBindingMember.CreateMember <UITableViewCell, bool?>(nameof(UITableViewCell.Selected), (info, target) => TableViewSourceBase.CellMediator.GetMediator(target, true).SelectedBind, (info, cell, arg3) => TableViewSourceBase.CellMediator.GetMediator(cell, true).SelectedBind = arg3, (info, cell, arg3) => TableViewSourceBase.CellMediator.GetMediator(cell, true).AddWithUnsubscriber(arg3))); }
public void CreateEventGenericSetterTest() { bool isInvoked = false; var source = new BindingSourceModel(); IEventListener listener = new EventListenerMock(); const string path = "path"; var property = AttachedBindingMember.CreateEvent <BindingSourceModel>(path, (info, o, arg3) => { info.ShouldNotBeNull(); o.ShouldEqual(source); arg3.ShouldEqual(listener); isInvoked = true; return(null); }); property.Path.ShouldEqual(path); property.Type.ShouldEqual(typeof(Delegate)); property.CanRead.ShouldBeTrue(); property.CanWrite.ShouldBeTrue(); property.MemberType.ShouldEqual(BindingMemberType.Event); property.SetValue(source, new object[] { listener }); isInvoked.ShouldBeTrue(); }
private static void Register(IBindingMemberProvider memberProvider) { BindingServiceProvider.ResourceResolver.AddType("UITextFieldViewMode", typeof(UITextFieldViewMode)); RegisterTableViewMembers(memberProvider); RegisterCollectionViewMembers(memberProvider); RegisterDialogMembers(memberProvider); //Object memberProvider.Register(AttachedBindingMember.CreateMember <object, object>(AttachedMemberConstants.ItemsSource, GetObjectItemsSource, SetObjectItemsSource, ObserveObjectItemsSource)); memberProvider.Register(CollectionViewManagerMember); memberProvider.Register(ContentViewManagerMember); memberProvider.Register(AttachedBindingMember.CreateAutoProperty <object, IDataTemplateSelector>(AttachedMemberConstants.ItemTemplate)); //UIView memberProvider.Register(AttachedBindingMember.CreateMember <UIView, object>(AttachedMemberConstants.Parent, (info, view) => ParentObserver.GetOrAdd(view).Parent, null, (info, view, arg3) => ParentObserver.GetOrAdd(view).AddWithUnsubscriber(arg3))); memberProvider.Register(AttachedBindingMember.CreateMember <UIView, object>(AttachedMemberConstants.FindByNameMethod, FindViewByName)); memberProvider.Register(ContentMember); memberProvider.Register(ContentTemplateMember); memberProvider.Register(AttachedBindingMember.CreateMember <UIView, bool>("Visible", (info, view) => !view.Hidden, (info, view, arg3) => view.Hidden = !arg3)); //UIButton memberProvider.Register(AttachedBindingMember.CreateMember <UIButton, string>("Title", (info, button) => button.CurrentTitle, (info, button, arg3) => button.SetTitle(arg3, UIControlState.Normal))); //UIDatePicker memberProvider.Register(AttachedBindingMember.CreateMember <UIDatePicker, DateTime>("Date", (info, picker) => picker.Date, (info, picker, arg3) => picker.Date = arg3, "ValueChanged")); //UISwitch memberProvider.Register(AttachedBindingMember.CreateMember <UISwitch, bool>("On", (info, picker) => picker.On, (info, picker, arg3) => picker.On = arg3, "ValueChanged")); //UIControl var clickMember = memberProvider.GetBindingMember(typeof(UIControl), "TouchUpInside", true, false); if (clickMember != null) { memberProvider.Register(typeof(UIControl), "Click", clickMember, true); } //UITextField NSNotificationCenter.DefaultCenter.AddObserver(UITextField.TextFieldTextDidChangeNotification, TextDidChangeNotification); memberProvider.Register(AttachedBindingMember.CreateEvent <UITextField>("TextChanged", SetTextFieldTextChanged)); //UITextView NSNotificationCenter.DefaultCenter.AddObserver(UITextView.TextDidChangeNotification, TextDidChangeNotification); memberProvider.Register(AttachedBindingMember.CreateEvent <UITextView>("TextChanged", SetTextFieldTextChanged)); //UILabel memberProvider.Register(AttachedBindingMember.CreateMember <UILabel, string>("TextSizeToFit", (info, label) => label.Text, (info, label, arg3) => { label.Text = arg3; label.SizeToFit(); })); //UITabBarController memberProvider.Register(TabBarSelectedItemMember); memberProvider.Register(AttachedBindingMember.CreateAutoProperty <UITabBarController, IEnumerable>(AttachedMemberConstants.ItemsSource, TabBarItemsSourceChanged)); //UIViewController BindingServiceProvider.BindingMemberPriorities[ToolbarItemTemplate] = 1; memberProvider.Register(AttachedBindingMember.CreateAutoProperty <UIViewController, IEnumerable>("ToolbarItemsSource", ToolbarItemsSourceChanged)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty <UIViewController, IDataTemplateSelector>(ToolbarItemTemplate)); memberProvider.Register(AttachedBindingMember.CreateMember <UIViewController, string>("Title", (info, controller) => controller.Title, (info, controller, arg3) => controller.Title = arg3 ?? string.Empty)); memberProvider.Register( AttachedBindingMember.CreateMember <UIViewController, object>(AttachedMemberConstants.Parent, (info, controller) => { var parent = BindingExtensions.AttachedParentMember.GetValue(controller, null); if (parent == null) { parent = controller.ParentViewController ?? controller.PresentingViewController; } return(parent); }, (info, controller, arg3) => BindingExtensions.AttachedParentMember.SetValue(controller, arg3), (info, controller, arg3) => BindingExtensions.AttachedParentMember.TryObserve(controller, arg3))); //UISplitViewController memberProvider.Register(AttachedBindingMember.CreateAutoProperty <UISplitViewController, IEnumerable>(AttachedMemberConstants.ItemsSource, SplitViewControllerItemsSourceChanged)); //UIToolbar memberProvider.Register(AttachedBindingMember.CreateAutoProperty <UIToolbar, IEnumerable>(AttachedMemberConstants.ItemsSource, ToolbarItemsSourceChanged)); //UIPickerView memberProvider.Register(AttachedBindingMember.CreateAutoProperty <UIPickerView, IEnumerable>(AttachedMemberConstants.ItemsSource, PickerViewItemsSourceChanged)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty <UIPickerView, string>("DisplayMemberPath", PickerViewDisplayMemberPathChangedChanged)); memberProvider.Register( AttachedBindingMember.CreateMember <UIPickerView, object>(AttachedMemberConstants.SelectedItem, (info, view) => GetOrAddPickerViewModel(view).SelectedItem, (info, view, arg3) => GetOrAddPickerViewModel(view).SelectedItem = arg3, (info, view, arg3) => { var viewModel = GetOrAddPickerViewModel(view); return(BindingServiceProvider.WeakEventManager.TrySubscribe(viewModel, "SelectedItemChanged", arg3)); })); }
private static void RegisterMenuMembers(IBindingMemberProvider memberProvider) { //IMenu memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.Menu.ItemsSource, MenuItemsSourceChanged)); var menuEnabledMember = AttachedBindingMember.CreateAutoProperty(AttachedMembers.Menu.Enabled, (menu, args) => menu.SetGroupEnabled(0, args.NewValue.GetValueOrDefault())); memberProvider.Register(menuEnabledMember); memberProvider.Register("IsEnabled", menuEnabledMember); var menuVisibleMember = AttachedBindingMember.CreateAutoProperty(AttachedMembers.Menu.Visible, (menu, args) => menu.SetGroupVisible(0, args.NewValue.GetValueOrDefault())); memberProvider.Register(menuVisibleMember); memberProvider.Register("IsVisible", menuVisibleMember); //IMenuItem BindingBuilderExtensions.RegisterDefaultBindingMember(AttachedMembers.MenuItem.Click); memberProvider.Register(AttachedBindingMember.CreateNotifiableMember(AttachedMembers.MenuItem.IsChecked, (info, item) => item.IsChecked, (info, item, value) => { if (value == item.IsChecked) { return(false); } item.SetChecked(value); return(true); })); memberProvider.Register(AttachedBindingMember.CreateEvent(AttachedMembers.MenuItem.Click, SetClickEventValue, (item, args) => item.SetOnMenuItemClickListener(new MenuItemOnMenuItemClickListener(item)))); memberProvider.Register(AttachedBindingMember .CreateMember <IMenuItem, object>("AlphabeticShortcut", (info, item) => item.AlphabeticShortcut, (info, item, value) => { if (value is char) { item.SetAlphabeticShortcut((char)value); } else { item.SetAlphabeticShortcut(value.ToStringSafe()[0]); } })); memberProvider.Register(AttachedBindingMember .CreateMember(AttachedMembers.MenuItem.Icon, (info, item) => item.Icon, (info, item, value) => { if (value is int) { item.SetIcon((int)value); } else { item.SetIcon((Drawable)value); } })); memberProvider.Register(AttachedBindingMember .CreateMember <IMenuItem, bool>("IsCheckable", (info, item) => item.IsCheckable, (info, item, value) => item.SetCheckable(value))); var menuItemEnabled = AttachedBindingMember.CreateMember <IMenuItem, bool>(AttachedMemberConstants.Enabled, (info, item) => item.IsEnabled, (info, item, value) => item.SetEnabled(value)); memberProvider.Register(menuItemEnabled); memberProvider.Register("IsEnabled", menuItemEnabled); memberProvider.Register(AttachedBindingMember .CreateMember <IMenuItem, bool>("IsVisible", (info, item) => item.IsVisible, (info, item, value) => item.SetVisible(value))); memberProvider.Register(AttachedBindingMember .CreateMember <IMenuItem, object>("NumericShortcut", (info, item) => item.NumericShortcut, (info, item, value) => { if (value is char) { item.SetNumericShortcut((char)value); } else { item.SetNumericShortcut(value.ToStringSafe()[0]); } })); memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.MenuItem.Title, (info, item) => item.TitleFormatted.ToStringSafe(), (info, item, value) => item.SetTitle(value))); memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.MenuItem.TitleCondensed, (info, item) => item.TitleCondensedFormatted.ToStringSafe(), (info, item, value) => item.SetTitleCondensed(value))); }
private static void RegisterMenuMembers(IBindingMemberProvider memberProvider) { //IMenu memberProvider.Register(MenuItemsSourceMember); var menuEnabledMember = AttachedBindingMember.CreateAutoProperty <IMenu, bool?>(AttachedMemberConstants.Enabled, (menu, args) => menu.SetGroupEnabled(0, args.NewValue.GetValueOrDefault())); memberProvider.Register(menuEnabledMember); memberProvider.Register("IsEnabled", menuEnabledMember); var menuVisibleMember = AttachedBindingMember.CreateAutoProperty <IMenu, bool?>("Visible", (menu, args) => menu.SetGroupVisible(0, args.NewValue.GetValueOrDefault())); memberProvider.Register(menuVisibleMember); memberProvider.Register("IsVisible", menuVisibleMember); //IMenuItem #if !API8 memberProvider.Register(MenuItemActionViewMember); memberProvider.Register(MenuItemActionViewSelectorMember); memberProvider.Register(MenuItemActionProviderMember); memberProvider.Register(MenuItemActionProviderSelectorMember); #endif memberProvider.Register(IsCheckedMenuItemMember); memberProvider.Register(AttachedBindingMember.CreateEvent <IMenuItem>("Click", SetClickEventValue)); memberProvider.Register(AttachedBindingMember .CreateMember <IMenuItem, object>("AlphabeticShortcut", (info, item) => item.AlphabeticShortcut, (info, item, value) => { if (value is char) { item.SetAlphabeticShortcut((char)value); } else { item.SetAlphabeticShortcut(value.ToStringSafe()[0]); } })); memberProvider.Register(AttachedBindingMember .CreateMember <IMenuItem, object>("Icon", (info, item) => item.Icon, (info, item, value) => { if (value is int) { item.SetIcon((int)value); } else { item.SetIcon((Drawable)value); } })); memberProvider.Register(AttachedBindingMember .CreateMember <IMenuItem, bool>("IsCheckable", (info, item) => item.IsCheckable, (info, item, value) => item.SetCheckable(value))); var menuItemEnabled = AttachedBindingMember.CreateMember <IMenuItem, bool>(AttachedMemberConstants.Enabled, (info, item) => item.IsEnabled, (info, item, value) => item.SetEnabled(value)); memberProvider.Register(menuItemEnabled); memberProvider.Register("IsEnabled", menuItemEnabled); memberProvider.Register(AttachedBindingMember .CreateMember <IMenuItem, bool>("IsVisible", (info, item) => item.IsVisible, (info, item, value) => item.SetVisible(value))); memberProvider.Register(AttachedBindingMember .CreateMember <IMenuItem, object>("NumericShortcut", (info, item) => item.NumericShortcut, (info, item, value) => { if (value is char) { item.SetNumericShortcut((char)value); } else { item.SetNumericShortcut(value.ToStringSafe()[0]); } })); memberProvider.Register(AttachedBindingMember.CreateMember <IMenuItem, string>("Title", (info, item) => item.TitleFormatted.ToString(), (info, item, value) => item.SetTitle(value))); memberProvider.Register(AttachedBindingMember.CreateMember <IMenuItem, string>("TitleCondensed", (info, item) => item.TitleCondensedFormatted.ToString(), (info, item, value) => item.SetTitleCondensed(value))); #if !API8 memberProvider.Register(AttachedBindingMember .CreateMember <IMenuItem, bool>("IsActionViewExpanded", (info, item) => item.GetIsActionViewExpanded(), SetIsActionViewExpanded, ObserveIsActionViewExpanded, (item, args) => { #if API8SUPPORT item.SetOnActionExpandListener(new ActionViewExpandedListener(item)); #else item.SetOnActionExpandListener(ActionViewExpandedListener.Instance); #endif })); memberProvider.Register(AttachedBindingMember .CreateMember <IMenuItem, ShowAsAction>("ShowAsAction", null, (info, o, value) => o.SetShowAsActionFlags(value))); #endif }
static PlatformDataBindingModule() { SelecectedControllerChangedHandler = TabBarOnViewControllerSelected; //Object ItemsSourceMember = AttachedBindingMember.CreateAutoProperty <object, IEnumerable>(AttachedMemberConstants.ItemsSource, ObjectItemsSourceChanged); CollectionViewManagerMember = AttachedBindingMember.CreateAutoProperty <object, ICollectionViewManager>("CollectionViewManager"); ContentViewManagerMember = AttachedBindingMember.CreateAutoProperty <object, IContentViewManager>("ContentViewManager"); //UIView ContentMember = AttachedBindingMember.CreateAutoProperty <UIView, object>(AttachedMemberConstants.Content, ContentChanged); ContentTemplateMember = AttachedBindingMember.CreateAutoProperty <UIView, IDataTemplateSelector>(AttachedMemberConstants.ContentTemplate, ContentTemplateChanged); //UITableView TableViewSelectedItemChangedEvent = AttachedBindingMember.CreateEvent <UITableView>("SelectedItemChanged"); TableViewReadOnlyMember = AttachedBindingMember.CreateAutoProperty <UITableView, bool>("ReadOnly"); TableViewUseAnimationsMember = AttachedBindingMember.CreateAutoProperty <UITableView, bool?>("UseAnimations"); TableViewCellBindMember = AttachedBindingMember.CreateAutoProperty <UITableView, Action <UITableViewCell> >("CellBind"); TableViewAddAnimationMember = AttachedBindingMember.CreateAutoProperty <UITableView, UITableViewRowAnimation?>("AddAnimation"); TableViewRemoveAnimationMember = AttachedBindingMember.CreateAutoProperty <UITableView, UITableViewRowAnimation?>("RemoveAnimation"); TableViewReplaceAnimationMember = AttachedBindingMember.CreateAutoProperty <UITableView, UITableViewRowAnimation?>("ReplaceAnimation"); TableViewScrollPositionMember = AttachedBindingMember.CreateAutoProperty <UITableView, UITableViewScrollPosition?>("ScrollPosition"); TableViewDefaultCellStyleMember = AttachedBindingMember.CreateAutoProperty <UITableView, UITableViewCellStyle?>("CellStyle"); //UITableViewCell TableViewCellAccessoryButtonTappedEvent = AttachedBindingMember.CreateEvent <UITableViewCell>("AccessoryButtonTapped"); TableViewCellDeleteClickEvent = AttachedBindingMember.CreateEvent <UITableViewCell>("DeleteClick"); TableViewCellInsertClickEvent = AttachedBindingMember.CreateEvent <UITableViewCell>("InsertClick"); TableViewCellMoveableMember = AttachedBindingMember.CreateAutoProperty <UITableViewCell, bool?>("Moveable"); TitleForDeleteConfirmationMember = AttachedBindingMember.CreateAutoProperty <UITableViewCell, string>("TitleForDeleteConfirmation"); TableViewCellEditingStyleMember = AttachedBindingMember.CreateAutoProperty <UITableViewCell, UITableViewCellEditingStyle?>("EditingStyle"); TableViewCellShouldHighlightMember = AttachedBindingMember.CreateAutoProperty <UITableViewCell, bool?>("ShouldHighlight"); TableViewCellSelectedMember = AttachedBindingMember.CreateNotifiableMember <UITableViewCell, bool>( "Selected", (info, cell) => { var cellBindable = cell as UITableViewCellBindable; if (cellBindable == null) { return(cell.Selected); } return(cellBindable.SelectedBind); }, (info, cell, arg3) => { var cellBindable = cell as UITableViewCellBindable; if (cellBindable == null) { cell.Selected = arg3; } else { cellBindable.SelectedBind = arg3; } return(true); }); TableViewCellHighlightedMember = AttachedBindingMember.CreateNotifiableMember <UITableViewCell, bool>( "Highlighted", (info, cell) => cell.Highlighted, (info, cell, arg3) => { if (cell.Highlighted == arg3) { return(false); } cell.Highlighted = arg3; return(true); }); TableViewCellEditingMember = AttachedBindingMember.CreateNotifiableMember <UITableViewCell, bool>( "Editing", (info, cell) => cell.Editing, (info, cell, arg3) => { if (cell.Editing == arg3) { return(false); } cell.Editing = arg3; return(true); }); //UICollectionView CollectionViewUseAnimationsMember = AttachedBindingMember.CreateAutoProperty <UICollectionView, bool?>("UseAnimations"); CollectionViewScrollPositionMember = AttachedBindingMember.CreateAutoProperty <UICollectionView, UICollectionViewScrollPosition?>("ScrollPosition"); CollectionViewSelectedItemChangedEvent = AttachedBindingMember.CreateEvent <UICollectionView>("SelectedItemChanged"); //UICollectionViewCell CollectionViewCellShouldSelectMember = AttachedBindingMember.CreateAutoProperty <UICollectionViewCell, bool?>("ShouldSelect"); CollectionViewCellShouldDeselectMember = AttachedBindingMember.CreateAutoProperty <UICollectionViewCell, bool?>("ShouldDeselect"); CollectionViewCellShouldHighlightMember = AttachedBindingMember.CreateAutoProperty <UICollectionViewCell, bool?>("ShouldHighlight"); CollectionViewCellSelectedMember = AttachedBindingMember .CreateNotifiableMember <UICollectionViewCell, bool>("Selected", (info, cell) => cell.Selected, (info, cell, arg3) => { var cellBindable = cell as UICollectionViewCellBindable; if (cellBindable == null) { cell.Selected = arg3; } else { cellBindable.SelectedBind = arg3; } return(true); }); CollectionViewCellHighlightedMember = AttachedBindingMember .CreateNotifiableMember <UICollectionViewCell, bool>("Highlighted", (info, cell) => cell.Highlighted, (info, cell, arg3) => { cell.Highlighted = arg3; return(true); }); //UITabBarController TabBarSelectedItemMember = AttachedBindingMember.CreateAutoProperty <UITabBarController, object>(AttachedMemberConstants.SelectedItem, TabBarSelectedItemChanged, TabBarSelectedItemAttached); }
private static void RegisterActionBarMembers(IBindingMemberProvider memberProvider) { //PopupMenu #if !APPCOMPAT memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.View.PopupMenuTemplate)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.View.PopupMenuPlacementTargetPath)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.View.PopupMenuPresenter)); #endif memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.View.PopupMenuEvent, PopupMenuEventChanged)); //Menu memberProvider.Register(AttachedBindingMember.CreateNotifiableMember(AttachedMembers.MenuItem.ActionView, (info, item) => item.GetActionView(), MenuItemUpdateActionView)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.MenuItem.ActionViewTemplateSelector, (o, args) => RefreshValue(o, AttachedMembers.MenuItem.ActionView))); memberProvider.Register(AttachedBindingMember.CreateNotifiableMember(AttachedMembers.MenuItem.ActionProvider, (info, item) => item.GetActionProvider(), MenuItemUpdateActionProvider)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.MenuItem.ActionProviderTemplateSelector, (o, args) => RefreshValue(o, AttachedMembers.MenuItem.ActionProvider))); memberProvider.Register(AttachedBindingMember .CreateMember(AttachedMembers.MenuItem.IsActionViewExpanded, (info, item) => item.GetIsActionViewExpanded(), SetIsActionViewExpanded, ObserveIsActionViewExpanded, (item, args) => item.SetOnActionExpandListener(new ActionViewExpandedListener(item)))); memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.MenuItem.ShowAsAction, null, (info, o, value) => o.SetShowAsActionFlags(value))); //ActionBar memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBarTab.Content.Override <ActionBar.Tab>())); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBar.ItemsSource.Override <ActionBar>(), (bar, args) => ActionBarUpdateItemsSource(bar))); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBar.SelectedItem.Override <ActionBar>(), ActionBarSelectedItemChanged)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBar.ContextActionBarVisible.Override <ActionBar>(), ActionBarContextActionBarVisibleChanged)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBar.ContextActionBarTemplate.Override <ActionBar>())); memberProvider.Register(AttachedBindingMember.CreateMember <ActionBar, object>(AttachedMemberConstants.ParentExplicit, (info, bar) => bar.ThemedContext.GetActivity(), null)); memberProvider.Register(AttachedBindingMember .CreateAutoProperty(AttachedMembers.ActionBar.BackgroundDrawable.Override <ActionBar>(), (actionBar, args) => { if (args.NewValue is int) { actionBar.SetBackgroundDrawable( actionBar.ThemedContext.Resources.GetDrawable((int)args.NewValue)); } else { actionBar.SetBackgroundDrawable((Drawable)args.NewValue); } })); memberProvider.Register(AttachedBindingMember .CreateNotifiableMember(AttachedMembers.ActionBar.CustomView.Override <ActionBar>(), (info, actionBar) => actionBar.CustomView, (info, actionBar, value) => { if (actionBar.CustomView != null) { ParentObserver.GetOrAdd(actionBar.CustomView).Parent = null; } if (value is int) { value = actionBar.ThemedContext.GetBindableLayoutInflater().Inflate((int)value, null); } actionBar.CustomView = (View)value; if (actionBar.CustomView != null) { ParentObserver.GetOrAdd(actionBar.CustomView).Parent = actionBar; } return(true); })); memberProvider.Register(AttachedBindingMember .CreateAutoProperty(AttachedMembers.ActionBar.DisplayHomeAsUpEnabled.Override <ActionBar>(), (actionBar, args) => actionBar.SetDisplayHomeAsUpEnabled(args.NewValue))); memberProvider.Register(AttachedBindingMember .CreateNotifiableMember(AttachedMembers.ActionBar.DisplayOptions.Override <ActionBar>().Cast <ActionBarDisplayOptions>(), (info, actionBar) => actionBar.GetActionBarDisplayOptions(), (info, actionBar, value) => { actionBar.SetActionBarDisplayOptions(value); return(true); })); memberProvider.Register(AttachedBindingMember .CreateAutoProperty(AttachedMembers.ActionBar.DisplayShowCustomEnabled.Override <ActionBar>(), (actionBar, args) => actionBar.SetDisplayShowCustomEnabled(args.NewValue))); memberProvider.Register(AttachedBindingMember .CreateAutoProperty(AttachedMembers.ActionBar.DisplayShowHomeEnabled.Override <ActionBar>(), (actionBar, args) => actionBar.SetDisplayShowHomeEnabled(args.NewValue))); memberProvider.Register(AttachedBindingMember .CreateAutoProperty(AttachedMembers.ActionBar.DisplayShowTitleEnabled.Override <ActionBar>(), (actionBar, args) => actionBar.SetDisplayShowTitleEnabled(args.NewValue))); memberProvider.Register(AttachedBindingMember .CreateAutoProperty(AttachedMembers.ActionBar.DisplayUseLogoEnabled.Override <ActionBar>(), (actionBar, args) => actionBar.SetDisplayUseLogoEnabled(args.NewValue))); memberProvider.Register(AttachedBindingMember .CreateAutoProperty(AttachedMembers.ActionBar.HomeButtonEnabled.Override <ActionBar>(), (actionBar, args) => actionBar.SetHomeButtonEnabled(args.NewValue))); memberProvider.Register(AttachedBindingMember .CreateAutoProperty(AttachedMembers.ActionBar.Icon.Override <ActionBar>(), (actionBar, args) => { if (args.NewValue is int) { actionBar.SetIcon((int)args.NewValue); } else { actionBar.SetIcon((Drawable)args.NewValue); } })); memberProvider.Register(AttachedBindingMember .CreateAutoProperty(AttachedMembers.ActionBar.Logo.Override <ActionBar>(), (actionBar, args) => { if (args.NewValue is int) { actionBar.SetLogo((int)args.NewValue); } else { actionBar.SetLogo((Drawable)args.NewValue); } })); memberProvider.Register(AttachedBindingMember .CreateNotifiableMember(AttachedMembers.ActionBar.NavigationMode.Override <ActionBar>().Cast <ActionBarNavigationMode>(), (info, actionBar) => actionBar.GetNavigationMode(), ActionBarSetNavigationMode)); memberProvider.Register(AttachedBindingMember .CreateAutoProperty(AttachedMembers.ActionBar.SplitBackgroundDrawable.Override <ActionBar>(), (actionBar, args) => { if (args.NewValue is int) { actionBar.SetSplitBackgroundDrawable( actionBar.ThemedContext.Resources.GetDrawable((int)args.NewValue)); } else { actionBar.SetSplitBackgroundDrawable((Drawable)args.NewValue); } })); memberProvider.Register(AttachedBindingMember .CreateAutoProperty(AttachedMembers.ActionBar.StackedBackgroundDrawable.Override <ActionBar>(), (actionBar, args) => { if (args.NewValue is int) { actionBar.SetStackedBackgroundDrawable( actionBar.ThemedContext.Resources.GetDrawable((int)args.NewValue)); } else { actionBar.SetStackedBackgroundDrawable((Drawable)args.NewValue); } })); memberProvider.Register(AttachedBindingMember .CreateNotifiableMember(AttachedMembers.ActionBar.IsShowing.Override <ActionBar>(), (info, actionBar) => actionBar.IsShowing, SetActionBarIsShowing)); memberProvider.Register(AttachedBindingMember .CreateNotifiableMember <ActionBar, string>("Subtitle", (info, actionBar) => actionBar.Subtitle, (info, actionBar, value) => { actionBar.Subtitle = value; return(true); })); memberProvider.Register(AttachedBindingMember .CreateNotifiableMember <ActionBar, string>("Title", (info, actionBar) => actionBar.Title, (info, actionBar, value) => { actionBar.Title = value; return(true); })); memberProvider.Register(AttachedBindingMember .CreateNotifiableMember(AttachedMembers.ActionBar.Visible.Override <ActionBar>(), (info, actionBar) => actionBar.IsShowing, SetActionBarIsShowing)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBar.DropDownItemTemplate.Override <ActionBar>())); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBar.DropDownItemTemplateSelector.Override <ActionBar>())); //ActionBar.Tab memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBarTab.ContentTemplateSelector.Override <ActionBar.Tab>())); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBarTab.ContentTemplate.Override <ActionBar.Tab>())); memberProvider.Register(AttachedBindingMember .CreateNotifiableMember <ActionBar.Tab, string>("ContentDescription", (info, tab) => tab.ContentDescription, (info, tab, value) => { tab.SetContentDescription(value); return(true); })); memberProvider.Register(AttachedBindingMember .CreateNotifiableMember(AttachedMembers.ActionBarTab.CustomView.Override <ActionBar.Tab>(), (info, tab) => tab.CustomView, (info, tab, value) => { if (tab.CustomView != null) { ParentObserver.GetOrAdd(tab.CustomView).Parent = null; } if (value is int) { value = GetContextFromItem(tab).GetBindableLayoutInflater().Inflate((int)value, null); } tab.SetCustomView((View)value); if (tab.CustomView != null) { ParentObserver.GetOrAdd(tab.CustomView).Parent = tab; } return(true); })); memberProvider.Register(AttachedBindingMember .CreateNotifiableMember(AttachedMembers.ActionBarTab.Icon.Override <ActionBar.Tab>(), (info, tab) => tab.Icon, (info, tab, value) => { if (value is int) { tab.SetIcon((int)value); } else { tab.SetIcon((Drawable)value); } return(true); })); memberProvider.Register(AttachedBindingMember .CreateNotifiableMember <ActionBar.Tab, string>("Text", (info, tab) => tab.Text, (info, tab, value) => { tab.SetText(value); return(true); })); memberProvider.Register(AttachedBindingMember .CreateNotifiableMember <ActionBar.Tab, Object>("Tag", (info, tab) => tab.Tag, (info, tab, value) => { tab.SetTag(value); return(true); })); memberProvider.Register(AttachedBindingMember.CreateMember <ActionBar, HomeButtonImpl>("HomeButton", (info, bar) => HomeButtonImpl.GetOrAdd(bar), null)); memberProvider.Register(AttachedBindingMember.CreateEvent <HomeButtonImpl>("Click", (info, homeButton, arg3) => homeButton.AddWithUnsubscriber(arg3))); //SearchView BindingBuilderExtensions.RegisterDefaultBindingMember <SearchView>(() => v => v.Query); var queryMember = AttachedBindingMember.CreateMember <SearchView, string>("Query", (info, searchView) => searchView.Query, (info, searchView, value) => searchView.SetQuery(value, false), "QueryTextChange"); memberProvider.Register(queryMember); memberProvider.Register("Text", queryMember); }
private static void RegisterCollectionViewMembers(IBindingMemberProvider memberProvider) { BindingServiceProvider.ResourceResolver.AddType(typeof(UICollectionViewScrollPosition)); BindingServiceProvider.ResourceResolver.AddType(typeof(UICollectionViewScrollDirection)); BindingServiceProvider.BindingMemberPriorities[AttachedMembers.UICollectionView.UseAnimations] = BindingServiceProvider.TemplateMemberPriority + 1; BindingServiceProvider.BindingMemberPriorities[AttachedMembers.UICollectionView.ScrollPosition] = BindingServiceProvider.TemplateMemberPriority + 1; //UICollectionView BindingBuilderExtensions.RegisterDefaultBindingMember(AttachedMembers.UIView.ItemsSource.Override <UICollectionView>()); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UICollectionView.UseAnimations)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UICollectionView.ScrollPosition)); memberProvider.Register(AttachedBindingMember.CreateEvent(AttachedMembers.UICollectionView.SelectedItemChangedEvent)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UIView.ItemsSource.Override <UICollectionView>(), CollectionViewItemsSourceChanged)); memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.UICollectionView.SelectedItem, GetCollectionViewSelectedItem, SetCollectionViewSelectedItem, (info, view, arg3) => (IDisposable)view.SetBindingMemberValue(AttachedMembers.UICollectionView.SelectedItemChangedEvent, arg3))); var itemTemplateMember = AttachedBindingMember.CreateAutoProperty(AttachedMembers.UICollectionView.ItemTemplateSelector, (view, args) => args.NewValue?.Initialize(view)); memberProvider.Register(itemTemplateMember); memberProvider.Register(typeof(UICollectionView), AttachedMemberConstants.ItemTemplate, itemTemplateMember, true); //UICollectionViewCell memberProvider.Register(AttachedBindingMember.CreateEvent(AttachedMembers.UICollectionViewCell.ClickEvent)); memberProvider.Register(AttachedBindingMember .CreateNotifiableMember(AttachedMembers.UICollectionViewCell.Selected, (info, cell) => { if (CollectionViewSourceBase.HasMask(cell, CollectionViewSourceBase.InitializingStateMask)) { return(null); } var cellBindable = cell as UICollectionViewCellBindable; if (cellBindable == null) { return(cell.Selected); } return(cellBindable.SelectedBind.GetValueOrDefault()); }, (info, cell, arg3) => { var cellBindable = cell as UICollectionViewCellBindable; if (cellBindable == null) { cell.Selected = arg3.GetValueOrDefault(); } else { cellBindable.SelectedBind = arg3; } return(true); })); memberProvider.Register(AttachedBindingMember .CreateNotifiableMember(AttachedMembers.UICollectionViewCell.Highlighted, (info, cell) => cell.Highlighted, (info, cell, arg3) => { cell.Highlighted = arg3; return(true); })); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UICollectionViewCell.ShouldHighlight)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UICollectionViewCell.ShouldDeselect)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UICollectionViewCell.ShouldSelect)); }
private static void RegisterTableViewMembers(IBindingMemberProvider memberProvider) { BindingServiceProvider.ResourceResolver.AddType(typeof(UITableViewRowAnimation)); BindingServiceProvider.ResourceResolver.AddType(typeof(UITableViewScrollPosition)); BindingServiceProvider.ResourceResolver.AddType(typeof(UITableViewCellEditingStyle)); BindingServiceProvider.ResourceResolver.AddType(typeof(UITableViewCellAccessory)); BindingServiceProvider.ResourceResolver.AddType(typeof(UITableViewCellSelectionStyle)); BindingServiceProvider.ResourceResolver.AddType(typeof(UITableViewCellSeparatorStyle)); BindingServiceProvider.ResourceResolver.AddType(typeof(UITableViewCellStyle)); BindingServiceProvider.BindingMemberPriorities[AttachedMembers.UITableView.UseAnimations] = BindingServiceProvider.TemplateMemberPriority + 1; BindingServiceProvider.BindingMemberPriorities[AttachedMembers.UITableView.AddAnimation] = BindingServiceProvider.TemplateMemberPriority + 1; BindingServiceProvider.BindingMemberPriorities[AttachedMembers.UITableView.RemoveAnimation] = BindingServiceProvider.TemplateMemberPriority + 1; BindingServiceProvider.BindingMemberPriorities[AttachedMembers.UITableView.ReplaceAnimation] = BindingServiceProvider.TemplateMemberPriority + 1; BindingServiceProvider.BindingMemberPriorities[AttachedMembers.UITableView.ScrollPosition] = BindingServiceProvider.TemplateMemberPriority + 1; //UITableView BindingBuilderExtensions.RegisterDefaultBindingMember(AttachedMembers.UIView.ItemsSource.Override <UITableView>()); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableView.ReadOnly)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableView.AddAnimation)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableView.RemoveAnimation)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableView.ReplaceAnimation)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableView.ScrollPosition)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableView.UseAnimations)); memberProvider.Register(AttachedBindingMember.CreateEvent(AttachedMembers.UITableView.SelectedItemChangedEvent)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UIView.ItemsSource.Override <UITableView>(), TableViewItemsSourceChanged)); memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.UITableView.SelectedItem, GetTableViewSelectedItem, SetTableViewSelectedItem, (info, view, arg3) => (IDisposable)view.SetBindingMemberValue(AttachedMembers.UITableView.SelectedItemChangedEvent, arg3))); var itemTemplateMember = AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableView.ItemTemplateSelector, (view, args) => args.NewValue?.Initialize(view)); memberProvider.Register(itemTemplateMember); memberProvider.Register(typeof(UITableView), AttachedMemberConstants.ItemTemplate, itemTemplateMember, true); //UITableViewCell BindingBuilderExtensions.RegisterDefaultBindingMember <UITableViewCell>(() => c => c.TextLabel.Text); var member = AttachedBindingMember.CreateEvent(AttachedMembers.UITableViewCell.AccessoryButtonTappedEvent); memberProvider.Register(member); memberProvider.Register("Click", member); memberProvider.Register(AttachedBindingMember.CreateEvent(AttachedMembers.UITableViewCell.DeleteClickEvent)); memberProvider.Register(AttachedBindingMember.CreateEvent(AttachedMembers.UITableViewCell.InsertClickEvent)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableViewCell.Moveable)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableViewCell.TitleForDeleteConfirmation)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableViewCell.EditingStyle)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableViewCell.ShouldHighlight)); memberProvider.Register(AttachedBindingMember.CreateEvent(AttachedMembers.UITableViewCell.ClickEvent)); memberProvider.Register(AttachedBindingMember.CreateNotifiableMember( AttachedMembers.UITableViewCell.Selected, (info, cell) => { if (TableViewSourceBase.HasMask(cell, TableViewSourceBase.InitializingStateMask)) { return(null); } var cellBindable = cell as UITableViewCellBindable; if (cellBindable == null) { return(cell.Selected); } return(cellBindable.SelectedBind.GetValueOrDefault()); }, (info, cell, arg3) => { var cellBindable = cell as UITableViewCellBindable; if (cellBindable == null) { cell.Selected = arg3.GetValueOrDefault(); } else { cellBindable.SelectedBind = arg3; } return(true); })); memberProvider.Register(AttachedBindingMember.CreateNotifiableMember( AttachedMembers.UITableViewCell.Highlighted, (info, cell) => cell.Highlighted, (info, cell, arg3) => { if (cell.Highlighted == arg3) { return(false); } cell.Highlighted = arg3; return(true); })); memberProvider.Register(AttachedBindingMember.CreateNotifiableMember( AttachedMembers.UITableViewCell.Editing, (info, cell) => cell.Editing, (info, cell, arg3) => { if (cell.Editing == arg3) { return(false); } cell.Editing = arg3; return(true); })); }
private static void Register(IBindingMemberProvider memberProvider) { BindingServiceProvider.ResourceResolver.AddType(typeof(UITextFieldViewMode)); RegisterTableViewMembers(memberProvider); RegisterCollectionViewMembers(memberProvider); RegisterDialogMembers(memberProvider); BindingBuilderExtensions.RegisterDefaultBindingMember(AttachedMembers.UIBarButtonItem.ClickEvent); BindingBuilderExtensions.RegisterDefaultBindingMember <UISearchBar>(() => t => t.Text); BindingBuilderExtensions.RegisterDefaultBindingMember <UISlider>(() => t => t.Value); BindingBuilderExtensions.RegisterDefaultBindingMember <UIProgressView>(() => t => t.Progress); //Object var itemsSourceMember = AttachedBindingMember.CreateAutoProperty <object, IEnumerable>(AttachedMemberConstants.ItemsSource, ObjectItemsSourceChanged); var defaultMemberRegistration = new DefaultAttachedMemberRegistration <IEnumerable>(itemsSourceMember); memberProvider.Register(defaultMemberRegistration.ToAttachedBindingMember <object>()); memberProvider.Register(AttachedBindingMember.CreateAutoProperty <object, ICollectionViewManager>(AttachedMembers.UIView.CollectionViewManager.Path)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty <object, IContentViewManager>(AttachedMembers.UIView.ContentViewManager.Path)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(ItemsSourceGeneratorBase.MemberDescriptor, (o, args) => { IEnumerable itemsSource = null; if (args.OldValue != null) { itemsSource = args.OldValue.ItemsSource; args.OldValue.SetItemsSource(null); } if (args.NewValue != null) { args.NewValue.SetItemsSource(itemsSource); } })); var itemTemplateMember = AttachedBindingMember.CreateAutoProperty <object, IDataTemplateSelector>(AttachedMemberConstants.ItemTemplateSelector); memberProvider.Register(itemTemplateMember); memberProvider.Register(typeof(object), AttachedMemberConstants.ItemTemplate, itemTemplateMember, true); //UIView memberProvider.Register(AttachedBindingMember.CreateMember <UIView, object>(AttachedMemberConstants.Parent, (info, view) => ParentObserver.GetOrAdd(view).Parent, (info, view, arg3) => ParentObserver.GetOrAdd(view).Parent = arg3, (info, view, arg3) => ParentObserver.GetOrAdd(view).AddWithUnsubscriber(arg3))); memberProvider.Register(AttachedBindingMember.CreateMember <UIView, object>(AttachedMemberConstants.FindByNameMethod, FindViewByName)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UIView.Content, ContentChanged)); var member = AttachedBindingMember.CreateAutoProperty(AttachedMembers.UIView.ContentTemplateSelector, ContentTemplateChanged); memberProvider.Register(member); memberProvider.Register(typeof(UIView), AttachedMemberConstants.ContentTemplate, member, true); memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.UIView.Visible, (info, view) => !view.Hidden, (info, view, arg3) => view.Hidden = !arg3)); //UISegmentedControl BindingBuilderExtensions.RegisterDefaultBindingMember <UISegmentedControl>(() => t => t.SelectedSegment); memberProvider.Register(AttachedBindingMember.CreateMember <UISegmentedControl, int>("SelectedSegment", (info, control) => (int)control.SelectedSegment, (info, control, arg3) => control.SelectedSegment = arg3, "ValueChanged")); //UIButton BindingBuilderExtensions.RegisterDefaultBindingMember(AttachedMembers.UIControl.ClickEvent.Override <UIButton>()); memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.UIButton.Title, (info, button) => button.CurrentTitle, (info, button, arg3) => button.SetTitle(arg3, button.State))); memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.UIButton.State, (info, button) => button.State, (info, button, arg3) => button.SetTitle(button.CurrentTitle, arg3))); //UIDatePicker BindingBuilderExtensions.RegisterDefaultBindingMember(AttachedMembers.UIDatePicker.Date); memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.UIDatePicker.Date, (info, picker) => NSDateToDateTime(picker.Date), (info, picker, arg3) => picker.Date = DateTimeToNSDate(arg3), "ValueChanged")); //UISwitch BindingBuilderExtensions.RegisterDefaultBindingMember(AttachedMembers.UISwitch.On); memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.UISwitch.On, (info, picker) => picker.On, (info, picker, arg3) => picker.On = arg3, "ValueChanged")); //UIControl var clickMember = memberProvider.GetBindingMember(typeof(UIControl), "TouchUpInside", true, false); if (clickMember != null) { memberProvider.Register(typeof(UIControl), "Click", clickMember, true); } //UITextField BindingBuilderExtensions.RegisterDefaultBindingMember <UITextField>(() => t => t.Text); NSNotificationCenter.DefaultCenter.AddObserver(UITextField.TextFieldTextDidChangeNotification, TextDidChangeNotification); memberProvider.Register(AttachedBindingMember.CreateEvent(AttachedMembers.UITextField.TextChangedEvent, SetTextFieldTextChanged)); //UITextView BindingBuilderExtensions.RegisterDefaultBindingMember <UITextView>(() => t => t.Text); NSNotificationCenter.DefaultCenter.AddObserver(UITextView.TextDidChangeNotification, TextDidChangeNotification); memberProvider.Register(AttachedBindingMember.CreateEvent(AttachedMembers.UITextView.TextChangedEvent, SetTextFieldTextChanged)); //UILabel BindingBuilderExtensions.RegisterDefaultBindingMember <UILabel>(() => t => t.Text); memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.UILabel.TextSizeToFit, (info, label) => label.Text, (info, label, arg3) => { label.Text = arg3; label.SizeToFit(); })); //UIViewController BindingServiceProvider.BindingMemberPriorities["ToolbarItemTemplate"] = BindingServiceProvider.TemplateMemberPriority; BindingServiceProvider.BindingMemberPriorities[AttachedMembers.UIViewController.ToolbarItemTemplateSelector] = BindingServiceProvider.TemplateMemberPriority; memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UIViewController.ToastTemplateSelector)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UIViewController.ToolbarItemsSource, ToolbarItemsSourceChanged)); var templateMember = AttachedBindingMember.CreateAutoProperty(AttachedMembers.UIViewController.ToolbarItemTemplateSelector); memberProvider.Register(templateMember); memberProvider.Register(typeof(UIViewController), "ToolbarItemTemplate", templateMember, true); memberProvider.Register(AttachedBindingMember.CreateMember <UIViewController, string>("Title", (info, controller) => controller.Title, (info, controller, arg3) => controller.Title = arg3 ?? string.Empty)); memberProvider.Register(AttachedBindingMember.CreateMember <UIViewController, object>(AttachedMemberConstants.ParentExplicit, (info, controller) => controller.ParentViewController ?? controller.PresentingViewController ?? controller.SplitViewController, null)); //UITabBarController BindingBuilderExtensions.RegisterDefaultBindingMember(AttachedMembers.UITabBarController.ItemsSource); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITabBarController.SelectedItem, TabBarSelectedItemChanged, TabBarSelectedItemAttached)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITabBarController.ItemsSource, TabBarItemsSourceChanged)); //UISplitViewController memberProvider.Register(AttachedBindingMember.CreateNotifiableMember(AttachedMembers.UISplitViewController.MasterView, (info, controller) => { if (controller.ViewControllers.Length == 2) { return(controller.ViewControllers[0]); } return(null); }, (info, controller, arg3) => { UpdateMasterDetailController(controller, arg3, true); return(true); })); memberProvider.Register(AttachedBindingMember.CreateNotifiableMember(AttachedMembers.UISplitViewController.DetailView, (info, controller) => { if (controller.ViewControllers.Length == 2) { return(controller.ViewControllers[1]); } return(null); }, (info, controller, arg3) => { UpdateMasterDetailController(controller, arg3, false); return(true); })); //UIToolbar BindingBuilderExtensions.RegisterDefaultBindingMember(AttachedMembers.UIView.ItemsSource.Override <UIToolbar>()); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UIView.ItemsSource.Override <UIToolbar>(), ToolbarItemsSourceChanged)); //UIPickerView BindingBuilderExtensions.RegisterDefaultBindingMember(AttachedMembers.UIView.ItemsSource.Override <UIPickerView>()); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UIView.ItemsSource.Override <UIPickerView>(), PickerViewItemsSourceChanged)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UIPickerView.DisplayMemberPath, PickerViewDisplayMemberPathChangedChanged)); memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.UIPickerView.SelectedItem, (info, view) => GetOrAddPickerViewModel(view).SelectedItem, (info, view, arg3) => GetOrAddPickerViewModel(view).SelectedItem = arg3, (info, view, arg3) => { var viewModel = GetOrAddPickerViewModel(view); return(BindingServiceProvider.WeakEventManager.TrySubscribe(viewModel, "SelectedItemChanged", arg3)); })); }