/// <summary> /// Shows the flyout placed in relation to the specified element, and use this element as parent for content items. /// </summary> /// <param name="flyoutBase">The specified flayout.</param> /// <param name="placementTarget">The element to use as the flyout's placement target.</param> public static void ShowAtEx([NotNull] this FlyoutBase flyoutBase, [NotNull] FrameworkElement placementTarget) { Should.NotBeNull(flyoutBase, "flyoutBase"); Should.NotBeNull(placementTarget, "placementTarget"); var flyout = flyoutBase as Flyout; if (flyout == null) { var menuFlyout = flyoutBase as MenuFlyout; if (menuFlyout != null && menuFlyout.Items != null) { foreach (MenuFlyoutItemBase item in menuFlyout.Items) { ParentObserver.GetOrAdd(item).Parent = placementTarget; } } } else { var content = flyout.Content as FrameworkElement; if (content != null) { ParentObserver.GetOrAdd(content).Parent = placementTarget; } } flyoutBase.ShowAt(placementTarget); }
public override UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath) { var selector = _itemTemplateProvider.TemplateSelector; if (selector == null) { throw new NotSupportedException("The ItemTemplate is null to create UICollectionViewCell use the ItemTemplate with ICollectionCellTemplateSelector value."); } object item = GetItemAt(indexPath); UICollectionViewCell cell; var cellTemplateSelectorSupportDequeueReusableCell = selector as ICollectionCellTemplateSelectorSupportDequeueReusableCell; if (cellTemplateSelectorSupportDequeueReusableCell == null) { cell = (UICollectionViewCell)collectionView.DequeueReusableCell(selector.GetIdentifier(item, collectionView), indexPath); } else { cell = cellTemplateSelectorSupportDequeueReusableCell.DequeueReusableCell(collectionView, item, indexPath); } cell.SetDataContext(item); if (!HasMask(cell, InitializedStateMask)) { cell.Tag |= InitializedStateMask; ParentObserver.GetOrAdd(cell).Parent = collectionView; selector.InitializeTemplate(collectionView, cell); InitializeCell(cell); } CellMediator.Attach(collectionView, cell, indexPath); return(cell); }
private static object GetViewParentValue(IBindingMemberInfo arg1, View view) { if (view.Id == Android.Resource.Id.Content) { return(view.Context.GetActivity()); } return(ParentObserver.GetOrAdd(view).Parent); }
public static void SetInputViewEx([NotNull] this UITextField textField, UIView view) { Should.NotBeNull(textField, "textField"); textField.InputView = view; if (view != null) { ParentObserver.GetOrAdd(view).Parent = textField; } }
public static void ShowEx <T, TParent>([NotNull] this T actionSheet, TParent parent, [NotNull] Action <T, TParent> showAction) where T : UIActionSheet { Should.NotBeNull(actionSheet, "actionSheet"); Should.NotBeNull(showAction, "showAction"); ParentObserver.GetOrAdd(actionSheet).Parent = parent; showAction(actionSheet, parent); }
private static bool MenuItemUpdateActionView(IBindingMemberInfo bindingMemberInfo, IMenuItem menuItem, object content) { var actionView = menuItem.GetActionView(); if (actionView != null) { ParentObserver.GetOrAdd(actionView).Parent = null; } object template = menuItem.GetBindingMemberValue(AttachedMembers.MenuItem.ActionViewTemplateSelector)?.SelectTemplate(content, menuItem); if (template != null) { content = template; } if (content == null) { #if APPCOMPAT MenuItemCompat.SetActionView(menuItem, null); #else menuItem.SetActionView(null); #endif return(true); } int viewId; if (int.TryParse(content.ToString(), out viewId)) { content = GetContextFromItem(menuItem).GetBindableLayoutInflater().Inflate(viewId, null); } actionView = content as View; if (actionView == null) { Type viewType = TypeCache <View> .Instance.GetTypeByName(content.ToString(), true, true); actionView = viewType.CreateView(GetContextFromItem(menuItem)); } #if APPCOMPAT MenuItemCompat.SetActionView(menuItem, actionView); #else menuItem.SetActionView(actionView); #endif ParentObserver.GetOrAdd(actionView).Parent = menuItem; var bindings = GetActionViewBind(menuItem); if (!string.IsNullOrEmpty(bindings)) { BindingServiceProvider.BindingProvider.CreateBindingsFromString(actionView, bindings, null); } return(true); }
private static bool MenuItemUpdateActionView(IBindingMemberInfo bindingMemberInfo, IMenuItem menuItem, object content) { var actionView = menuItem.GetActionView(); if (actionView != null) { ParentObserver.GetOrAdd(actionView).Parent = null; } var selector = MenuItemActionViewSelectorMember.GetValue(menuItem, null); if (selector != null) { object template = selector.SelectTemplate(content, menuItem); if (template != null) { content = template; } } if (content == null) { menuItem.SetActionView(null); return(true); } int viewId; if (int.TryParse(content.ToString(), out viewId)) { menuItem.SetActionView(viewId); actionView = menuItem.GetActionView(); } else { actionView = content as View; if (actionView == null) { Type viewType = TypeCache <View> .Instance.GetTypeByName(content.ToString(), false, true); actionView = viewType.CreateView(GetContextFromMenuItem(menuItem)); } menuItem.SetActionView(actionView); } ParentObserver.GetOrAdd(actionView).Parent = menuItem; var bindings = MenuItemTemplate.GetActionViewBind(menuItem); if (!string.IsNullOrEmpty(bindings)) { BindingServiceProvider.BindingProvider.CreateBindingsFromString(actionView, bindings, null); } return(true); }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { object item = GetItemAt(indexPath); var selector = _templateProvider.TableCellTemplateSelector; NSString cellIdentifier = selector == null ? GetCellIdentifier(item) : selector.GetIdentifier(item, tableView); UITableViewCell cell = tableView.DequeueReusableCell(cellIdentifier); if (cell == null) { if (selector != null) { cell = selector.SelectTemplate(tableView, cellIdentifier); } if (cell == null) { var cellStyle = tableView.GetBindingMemberValue(AttachedMembers.UITableView.CellStyle).GetValueOrDefault(UITableViewCellStyle.Default); cell = new UITableViewCellBindable(cellStyle, cellIdentifier); } } _lastCreatedCell = cell; _lastCreatedCellPath = indexPath; if (Equals(item, _selectedItem) && !cell.Selected) { tableView.SelectRow(indexPath, false, UITableViewScrollPosition.None); } cell.Tag |= InitializingStateMask; cell.SetDataContext(item); if (!HasMask(cell, InitializedStateMask)) { cell.Tag |= InitializedStateMask; ParentObserver.GetOrAdd(cell).Parent = tableView; SetCellBinding(tableView, cell); } cell.Tag &= ~InitializingStateMask; var initializableItem = cell as IHasDisplayCallback; if (initializableItem != null) { initializableItem.WillDisplay(); } return(cell); }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { object item = GetItemAt(indexPath); var selector = _templateProvider.TableCellTemplateSelector; if (selector == null) { throw new NotSupportedException("The ItemTemplate is null to create UITableViewCell use the ItemTemplate with ITableCellTemplateSelector value."); } UITableViewCell cell; if (selector is ITableCellTemplateSelectorSupportDequeueReusableCell) { cell = ((ITableCellTemplateSelectorSupportDequeueReusableCell)selector).DequeueReusableCell(tableView, item, indexPath); } else { cell = tableView.DequeueReusableCell(selector.GetIdentifier(item, tableView), indexPath); } _lastCreatedCell = cell; _lastCreatedCellPath = indexPath; if (Equals(item, _selectedItem) && !cell.Selected) { tableView.SelectRow(indexPath, false, UITableViewScrollPosition.None); } cell.Tag |= InitializingStateMask; cell.SetDataContext(item); if (!HasMask(cell, InitializedStateMask)) { cell.Tag |= InitializedStateMask; ParentObserver.GetOrAdd(cell).Parent = tableView; selector.InitializeTemplate(tableView, cell); } cell.Tag &= ~InitializingStateMask; (cell as IHasDisplayCallback)?.WillDisplay(); return(cell); }
public override UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath) { var selector = _itemTemplateProvider.CollectionCellTemplateSelector; if (selector == null) { throw new NotSupportedException("The ItemTemplate is null to create UICollectionViewCell use the ItemTemplate with ICollectionCellTemplateSelector value."); } object item = GetItemAt(indexPath); NSString identifier = selector.GetIdentifier(item, collectionView); var cell = (UICollectionViewCell)collectionView.DequeueReusableCell(identifier, indexPath); _lastCreatedCell = cell; _lastCreatedCellPath = indexPath; if (Equals(item, _selectedItem) && !cell.Selected) { collectionView.SelectItem(indexPath, false, UICollectionViewScrollPosition.None); } cell.Tag |= InitializingStateMask; cell.SetDataContext(item); if (!HasMask(cell, InitializedStateMask)) { cell.Tag |= InitializedStateMask; ParentObserver.GetOrAdd(cell).Parent = collectionView; selector.InitializeTemplate(collectionView, cell); } cell.Tag &= ~InitializingStateMask; var initializableItem = cell as IHasDisplayCallback; if (initializableItem != null) { initializableItem.WillDisplay(); } return(cell); }
private static void AddButtonOS7([NotNull] this UIActionSheet actionSheet, string title, string binding, IList <object> sources) { var id = Guid.NewGuid().ToString("N"); actionSheet.AddButton(id); var subviews = actionSheet.Subviews; UIButton button = null; if (subviews != null) { button = subviews.OfType <UIButton>().FirstOrDefault(view => view.CurrentTitle == id); } if (button == null) { actionSheet.AddButtonOS8(title, binding, sources); return; } button.SetTitle(title, button.State); ParentObserver.GetOrAdd(button).Parent = actionSheet; if (!string.IsNullOrEmpty(binding)) { button.SetBindings(binding, sources); } }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { object item = GetItemAt(indexPath); var selector = _templateProvider.TemplateSelector; if (selector == null) { throw new NotSupportedException("The ItemTemplate is null to create UITableViewCell use the ItemTemplate with ITableCellTemplateSelector value."); } var cellTemplateSelectorSupportDequeueReusableCell = selector as ITableCellTemplateSelectorSupportDequeueReusableCell; var cell = cellTemplateSelectorSupportDequeueReusableCell == null ? tableView.DequeueReusableCell(selector.GetIdentifier(item, tableView), indexPath) : cellTemplateSelectorSupportDequeueReusableCell.DequeueReusableCell(tableView, item, indexPath); cell.SetDataContext(item); if (!HasMask(cell, InitializedStateMask)) { cell.Tag |= InitializedStateMask; ParentObserver.GetOrAdd(cell).Parent = tableView; selector.InitializeTemplate(tableView, cell); InitializeCell(cell); } return(cell); }
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)); })); }
private static DependencyObject GetParentValue(IBindingMemberInfo bindingMemberInfo, FrameworkElement target) { return(ParentObserver.GetOrAdd(target).Parent); }
private static IDisposable ObserveParentMember(IBindingMemberInfo bindingMemberInfo, Element o, IEventListener arg3) { return(ParentObserver.GetOrAdd(o).AddWithUnsubscriber(arg3)); }
private static object GetParentValue(IBindingMemberInfo bindingMemberInfo, Element target) { return(ParentObserver.GetOrAdd(target).Parent); }
public static void RegisterActionBarMembers() { 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 .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(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>())); }
private static void SetViewParentValue(IBindingMemberInfo bindingMemberInfo, View view, object arg3) { ParentObserver.GetOrAdd(view).Parent = arg3; }
private static IDisposable ObserveViewParent(IBindingMemberInfo bindingMemberInfo, View view, IEventListener arg3) { return(ParentObserver.GetOrAdd(view).AddWithUnsubscriber(arg3)); }
public static void RegisterActionBarTabMembers() { MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBarTab.Content.Override <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>(nameof(ActionBar.Tab.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>(nameof(ActionBar.Tab.Text), (info, tab) => tab.Text, (info, tab, value) => { tab.SetText(value); return(true); })); MemberProvider.Register(AttachedBindingMember .CreateNotifiableMember <ActionBar.Tab, Object>(nameof(ActionBar.Tab.Tag), (info, tab) => tab.Tag, (info, tab, value) => { tab.SetTag(value); return(true); })); }
private static void RegisterActionBarMembers(IBindingMemberProvider memberProvider) { memberProvider.Register(ActionBarTabContentMember); memberProvider.Register(ActionBarSelectedItemMember); memberProvider.Register(ActionBarItemsSourceMember); memberProvider.Register(ActionBarContextActionBarTemplateMember); memberProvider.Register(ActionBarContextActionBarVisibleMember); memberProvider.Register(AttachedBindingMember .CreateMember <ActionBar, object>(AttachedMemberConstants.Parent, (info, bar) => bar.ThemedContext.GetActivity(), null)); memberProvider.Register(AttachedBindingMember .CreateAutoProperty <ActionBar, object>("BackgroundDrawable", (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 <ActionBar, object>("CustomView", (info, actionBar) => actionBar.CustomView, (info, actionBar, value) => { if (actionBar.CustomView != null) { ParentObserver.GetOrAdd(actionBar.CustomView).Parent = null; } if (value is int) { actionBar.SetCustomView((int)value); } else { actionBar.CustomView = (View)value; } if (actionBar.CustomView != null) { ParentObserver.GetOrAdd(actionBar.CustomView).Parent = actionBar; } return(true); })); memberProvider.Register(AttachedBindingMember .CreateAutoProperty <ActionBar, bool>("DisplayHomeAsUpEnabled", (actionBar, args) => actionBar.SetDisplayHomeAsUpEnabled(args.NewValue))); memberProvider.Register(AttachedBindingMember .CreateNotifiableMember <ActionBar, ActionBarDisplayOptions>("DisplayOptions", (info, actionBar) => actionBar.GetActionBarDisplayOptions(), (info, actionBar, value) => { actionBar.SetActionBarDisplayOptions(value); return(true); })); memberProvider.Register(AttachedBindingMember .CreateAutoProperty <ActionBar, bool>("DisplayShowCustomEnabled", (actionBar, args) => actionBar.SetDisplayShowCustomEnabled(args.NewValue))); memberProvider.Register(AttachedBindingMember .CreateAutoProperty <ActionBar, bool>("DisplayShowHomeEnabled", (actionBar, args) => actionBar.SetDisplayShowHomeEnabled(args.NewValue))); memberProvider.Register(AttachedBindingMember .CreateAutoProperty <ActionBar, bool>("DisplayShowTitleEnabled", (actionBar, args) => actionBar.SetDisplayShowTitleEnabled(args.NewValue))); memberProvider.Register(AttachedBindingMember .CreateAutoProperty <ActionBar, bool>("DisplayUseLogoEnabled", (actionBar, args) => actionBar.SetDisplayUseLogoEnabled(args.NewValue))); memberProvider.Register(AttachedBindingMember .CreateAutoProperty <ActionBar, bool>("HomeButtonEnabled", (actionBar, args) => actionBar.SetHomeButtonEnabled(args.NewValue))); memberProvider.Register(AttachedBindingMember .CreateAutoProperty <ActionBar, object>("Icon", (actionBar, args) => { if (args.NewValue is int) { actionBar.SetIcon((int)args.NewValue); } else { actionBar.SetIcon((Drawable)args.NewValue); } })); memberProvider.Register(AttachedBindingMember .CreateAutoProperty <ActionBar, object>("Logo", (actionBar, args) => { if (args.NewValue is int) { actionBar.SetLogo((int)args.NewValue); } else { actionBar.SetLogo((Drawable)args.NewValue); } })); memberProvider.Register(AttachedBindingMember .CreateNotifiableMember <ActionBar, ActionBarNavigationMode>("NavigationMode", (info, actionBar) => actionBar.GetNavigationMode(), ActionBarSetNavigationMode)); memberProvider.Register(AttachedBindingMember .CreateAutoProperty <ActionBar, object>("SplitBackgroundDrawable", (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 <ActionBar, object>("StackedBackgroundDrawable", (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 <ActionBar, bool>("IsShowing", (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 <ActionBar, bool>("Visible", (info, actionBar) => actionBar.IsShowing, SetActionBarIsShowing)); memberProvider.Register(AttachedBindingMember.CreateMember <ActionBar, View>("HomeButton", GetHomeButton, null)); memberProvider.Register( AttachedBindingMember.CreateAutoProperty <ActionBar, int?>(AttachedMemberNames.DropDownItemTemplate)); memberProvider.Register( AttachedBindingMember.CreateAutoProperty <ActionBar, IDataTemplateSelector>( AttachedMemberNames.DropDownItemTemplateSelector)); //ActionBar.Tab memberProvider.Register( AttachedBindingMember.CreateAutoProperty <ActionBar.Tab, IDataTemplateSelector>( AttachedMemberConstants.ContentTemplateSelector)); memberProvider.Register( AttachedBindingMember.CreateAutoProperty <ActionBar.Tab, int?>( AttachedMemberConstants.ContentTemplate)); memberProvider.Register(AttachedBindingMember .CreateNotifiableMember <ActionBar.Tab, string>("ContentDescription", (info, tab) => tab.ContentDescription, (info, tab, value) => { tab.SetContentDescription(value); return(true); })); memberProvider.Register(AttachedBindingMember .CreateNotifiableMember <ActionBar.Tab, object>("CustomView", (info, tab) => tab.CustomView, (info, tab, value) => { if (tab.CustomView != null) { ParentObserver.GetOrAdd(tab.CustomView).Parent = null; } if (value is int) { tab.SetCustomView((int)value); } else { tab.SetCustomView((View)value); } if (tab.CustomView != null) { ParentObserver.GetOrAdd(tab.CustomView).Parent = tab; } return(true); })); memberProvider.Register(AttachedBindingMember .CreateNotifiableMember <ActionBar.Tab, object>("Icon", (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); })); //SearchView 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 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 object GetViewParentValue(IBindingMemberInfo arg1, View view) { return(ParentObserver.GetOrAdd(view).Parent); }
private static void SetParentValue(IBindingMemberInfo bindingMemberInfo, Element element, object arg3) { ParentObserver.GetOrAdd(element).Parent = arg3; }
public static void RegisterViewMembers() { 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)); }
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)); })); }