Пример #1
0
        private static void BusyMessageChanged(View view, AttachedMemberChangedEventArgs <string> args)
        {
            var dialog = ProgressDialogAttachedProperty.GetValue(view, null);

            if (dialog == null)
            {
                dialog = new ProgressDialog(view.Context);
                ProgressDialogAttachedProperty.SetValue(view, dialog);
            }
            dialog.SetMessage(args.NewValue);
        }
Пример #2
0
        private static void AdapterViewSelectedItemChanged(AdapterView sender, AttachedMemberChangedEventArgs <object> args)
        {
            var adapter = GetAdapter(sender) as ItemsSourceAdapter;

            if (adapter == null)
            {
                return;
            }
            int position = adapter.GetPosition(args.NewValue);

            AdapterViewSelectedPositionMember.SetValue(sender, position);
        }
 private static void TabBarOnViewControllerSelected(object sender, UITabBarSelectionEventArgs args)
 {
     if (args.ViewController == null)
     {
         TabBarSelectedItemMember.SetValue(sender, BindingExtensions.NullValue);
     }
     else
     {
         TabBarSelectedItemMember.SetValue((UITabBarController)sender,
                                           BindingServiceProvider.ContextManager.GetBindingContext(args.ViewController).Value);
     }
 }
        public void AutoPropertyMemberChangeTest()
        {
            bool         isInvoked = false;
            var          source    = new BindingSourceModel();
            const string path      = "path";
            IAttachedBindingMemberInfo <object, object> property = AttachedBindingMember.CreateAutoProperty(path, typeof(string),
                                                                                                            (o, args) =>
            {
                isInvoked = true;
                o.ShouldEqual(source);
                args.OldValue.ShouldBeNull();
                args.NewValue.ShouldEqual(path);
            });

            property.SetValue(source, new object[] { path });
            isInvoked.ShouldBeTrue();

            isInvoked = false;
            property.SetValue(source, new object[] { path });
            isInvoked.ShouldBeFalse();
        }
 /// <summary>
 ///     Called to have the fragment instantiate its user interface view.
 /// </summary>
 public virtual View OnCreateView(int?viewId, LayoutInflater inflater, ViewGroup container,
                                  Bundle savedInstanceState, Func <LayoutInflater, ViewGroup, Bundle, View> baseOnCreateView)
 {
     ClearBindings();
     if (viewId.HasValue)
     {
         if (_bindings == null)
         {
             _bindings = new List <IDataBinding>();
         }
         Tuple <View, IList <IDataBinding> > tuple = inflater.CreateBindableView(viewId.Value, container, false);
         FragmentViewMember.SetValue(tuple.Item1, Target);
         BindingServiceProvider.ContextManager.GetBindingContext(tuple.Item1).Value = DataContext;
         _bindings.AddRange(tuple.Item2);
         return(tuple.Item1);
     }
     return(baseOnCreateView(inflater, container, savedInstanceState));
 }
Пример #6
0
        private static void AdapterViewSelectedItemPositionChanged(AdapterView sender,
                                                                   AttachedMemberChangedEventArgs <int> args)
        {
            if (!(sender is ListView) || ScrollToSelectedItemMember.GetValue(sender, null))
            {
                sender.SetSelection(args.NewValue);
            }

            var adapter = GetAdapter(sender) as ItemsSourceAdapter;

            if (adapter == null)
            {
                return;
            }
            object item = adapter.GetRawItem(args.NewValue);

            AdapterViewSelectedItemMember.SetValue(sender, item);
        }
        public void AutoPropertyTest()
        {
            var          source = new BindingSourceModel();
            const string path   = "path";
            Type         type   = typeof(string);
            IAttachedBindingMemberInfo <object, object> property = AttachedBindingMember.CreateAutoProperty(path, type);

            property.Path.ShouldEqual(path);
            property.Type.ShouldEqual(type);
            property.CanRead.ShouldBeTrue();
            property.CanWrite.ShouldBeTrue();
            property.Member.ShouldBeNull();
            property.MemberType.ShouldEqual(BindingMemberType.Attached);

            property.GetValue(source, null).ShouldBeNull();
            property.SetValue(source, new object[] { path });
            property.GetValue(source, null).ShouldEqual(path);
        }
        private static void ActionBarUpdateItemsSource(ActionBar actionBar)
        {
            switch (actionBar.GetNavigationMode())
            {
            case ActionBarNavigationMode.List:
                IItemsSourceAdapter sourceAdapter = ItemsSourceAdapter.Get(actionBar);
                if (sourceAdapter == null)
                {
                    sourceAdapter = ItemsSourceAdapter.Factory(actionBar, actionBar.ThemedContext, DataContext.Empty);
                    ItemsSourceAdapter.Set(actionBar, sourceAdapter);
                    actionBar.SetListNavigationCallbacks(sourceAdapter, new ActionBarNavigationListener(actionBar));
                }
                sourceAdapter.ItemsSource = ActionBarItemsSourceMember.GetValue(actionBar, null);
                break;

            case ActionBarNavigationMode.Standard:
                ActionBarSelectedItemMember.SetValue(actionBar, BindingExtensions.NullValue);
                actionBar.SetListNavigationCallbacks(null, null);
                var generator = ItemsSourceGeneratorBase.Get(actionBar);
                if (generator != null)
                {
                    generator.SetItemsSource(null);
                }
                var adapter = ItemsSourceAdapter.Get(actionBar);
                if (adapter != null)
                {
                    adapter.ItemsSource = null;
                }
                break;

            case ActionBarNavigationMode.Tabs:
                var tabGenerator = ItemsSourceGeneratorBase.Get(actionBar);
                if (tabGenerator != null)
                {
                    tabGenerator.SetItemsSource(ActionBarItemsSourceMember.GetValue(actionBar, null));
                }
                break;
            }
        }