private PropertyReference GetViewProperty(View view)
        {
            if (view == null)
            {
                return(null);
            }

            string viewMemberName = null;

            if (view.Tag != null)
            {
                var tag = view.Tag.ToString();
                var bp  = ViewDataBindings.ParseBindingParameters(tag);
                if (bp != null)
                {
                    viewMemberName = bp.ViewMemberName;
                }
            }
            if (viewMemberName != null)
            {
                return(new PropertyReference(view, viewMemberName));
            }

            ViewDataBindings.ViewDefaultPropertyOrFieldName.TryGetValue(view.GetType().FullName, out viewMemberName);
            return(new PropertyReference(view, viewMemberName));
        }
 public ViewDataBindingsHolder(View rootView, ViewModelBase viewModel, LayoutInflater layoutInflater, string idPrefix, ViewDataBindings.ViewExtensionPoints viewExtensionPoints)
 {
     this.viewModel = viewModel;
     bindings       = new ViewDataBindings(rootView, viewModel, layoutInflater, idPrefix, viewExtensionPoints);
     bindings.EnsureCommandBindings();  // Then add any command bindings that were not specified in code (based on the Id naming convention)
     AddHandlers();
     viewModel.RaisePropertiesChanged();
 }
Example #3
0
        /// <summary>
        /// Call InitializeBindings() in the ViewDidLoad method of a derived view class to create the data bindings and update the view with the current view model values.
        /// </summary>
        /// <param name="rootView">The view that should display the viewModel</param>
        /// <param name="viewModel">The view model</param>
        /// <param name="bindingsParameters">Optional binding parameters; use to override default parameter values for specific bindings, or as an alternative for specifying binding parameters in the view tag attribute in AXML. Note that any binding parameters specified in the tag attribute wil override bindingsParameters.</param>
        /// <param name="idPrefix">The name prefix used to match view Id to property name. Default value is the root view class name + "_"</param>
        protected void InitializeBindings(UIView rootView, ViewModelBase viewModel, BindingParameters[] bindingsParameters = null, string idPrefix = null)
        {
            Bindings       = new ViewDataBindings(viewModel, idPrefix ?? this.GetType().Name + "_", this);
            this.viewModel = viewModel;

            EnsureHandlersAreAdded();

            Bindings.AddBindings(bindingsParameters, rootView, NavigationItem);
        }
 /// <summary>
 /// Override this method in a derived adapter class to change how a data-bound value is set for specific views
 /// </summary>
 /// <param name="view"></param>
 /// <param name="value"></param>
 protected virtual void UpdateView(View view, object value)
 {
     if (viewExtensionPoints != null)
     {
         viewExtensionPoints.UpdateView(view, value);
     }
     else
     {
         ViewDataBindings.UpdateView(view, value);
     }
 }
 /// <summary>
 /// Override this method in a derived table view source class to change how a data-bound value is set for specific views
 /// </summary>
 /// <param name="viewProperty"></param>
 /// <param name="value"></param>
 protected virtual void UpdateView(PropertyReference viewProperty, object value)
 {
     if (viewExtensionPoints != null)
     {
         viewExtensionPoints.UpdateView(viewProperty, value);
     }
     else
     {
         ViewDataBindings.UpdateView(viewProperty, value);
     }
 }
            public ViewDataBindingsHolder(UIView rootView, ViewModelBase viewModel, string idPrefix, ViewDataBindings.IViewExtensionPoints viewExtensionPoints = null)
            {
                this.viewModel = viewModel;
                bindings       = new ViewDataBindings(viewModel, idPrefix, viewExtensionPoints);
                List <BindingParameters> bindingParametersList;

                if (ViewDataBindings.RootViewBindingParameters.TryGetValue(rootView, out bindingParametersList))
                {
                    Console.WriteLine("Adding cell bindings from markup ...");
                    ViewDataBindings.RootViewBindingParameters.Remove(rootView);                     // Remove the static reference to the views to prevent memory leaks. Note that if we would want to recreate the bindings later, we could also store the parameters list in the bindings.
                    bindings.AddBindings(bindingParametersList.ToArray());
                }

                AddHandlers();
                viewModel.RaisePropertiesChanged();
            }
Example #7
0
        /// <summary>
        /// Call InitializeBindings() in the ViewDidLoad method of a derived view class to create the data bindings and update the view with the current view model values.
        /// </summary>
        /// <param name="rootView">The view that should display the viewModel</param>
        /// <param name="viewModel">The view model</param>
        /// <param name="bindingsParameters">Optional binding parameters; use to override default parameter values for specific bindings, or as an alternative for specifying binding parameters in the view tag attribute in AXML. Note that any binding parameters specified in the tag attribute wil override bindingsParameters.</param>
        /// <param name="idPrefix">The name prefix used to match view Id to property name. Default value is the root view class name + "_"</param>
        protected void InitializeBindings(UIView rootView, ViewModelBase viewModel, BindingParameters[] bindingsParameters = null, string idPrefix = null)
        {
            Bindings       = new ViewDataBindings(rootView, viewModel, idPrefix ?? this.GetType().Name + "_", this);
            this.viewModel = viewModel;

            EnsureHandlersAreAdded();

            Bindings.AddBindings(bindingsParameters);             // First add any bindings that were specified in code
            // TODO: Bindings.EnsureCommandBindings();  // Then add any command bindings that were not specified in code (based on the Id naming convention)

            List <BindingParameters> bindingParametersList;

            if (ViewDataBindings.RootViewBindingParameters.TryGetValue(rootView, out bindingParametersList))
            {
                Console.WriteLine("Adding bindings from markup ...");
                ViewDataBindings.RootViewBindingParameters.Remove(rootView);                 // Remove the static reference to the views to prevent memory leaks. Note that if we would want to recreate the bindings later, we could also store the parameters list in the bindings.
                Bindings.AddBindings(bindingParametersList.ToArray());
            }
        }
Example #8
0
        /// <summary>
        /// Call InitializeBindings() in the ViewDidLoad method of a derived view class to create the data bindings and update the view with the current view model values.
        /// </summary>
        /// <param name="rootView">The view that should display the viewModel</param>
        /// <param name="viewModel">The view model</param>
        /// <param name="bindingsParameters">Optional binding parameters; use to override default parameter values for specific bindings, or as an alternative for specifying binding parameters in the view tag attribute in AXML. Note that any binding parameters specified in the tag attribute wil override bindingsParameters.</param>
        /// <param name="idPrefix">The name prefix used to match view Id to property name. Default value is the root view class name + "_"</param>
        protected void InitializeBindings(UIView rootView, ViewModelBase viewModel, BindingParameters[] bindingsParameters = null, string idPrefix = null)
        {
            Bindings = new ViewDataBindings(rootView, viewModel, idPrefix ?? this.GetType().Name + "_", this);
            this.viewModel = viewModel;

            EnsureHandlersAreAdded();

            Bindings.AddBindings(bindingsParameters); // First add any bindings that were specified in code
            // TODO: Bindings.EnsureCommandBindings();  // Then add any command bindings that were not specified in code (based on the Id naming convention)

            List<BindingParameters> bindingParametersList;
            if (ViewDataBindings.RootViewBindingParameters.TryGetValue(rootView, out bindingParametersList))
            {
                Console.WriteLine("Adding bindings from markup ...");
                ViewDataBindings.RootViewBindingParameters.Remove(rootView); // Remove the static reference to the views to prevent memory leaks. Note that if we would want to recreate the bindings later, we could also store the parameters list in the bindings.
                Bindings.AddBindings(bindingParametersList.ToArray());
            }
        }
Example #9
0
 /// <summary>
 /// Override this method in a derived view class to change how a data-bound value is set for specific views
 /// </summary>
 /// <param name="viewProperty"></param>
 /// <param name="value"></param>
 public virtual void UpdateView(PropertyReference viewProperty, object value)
 {
     ViewDataBindings.UpdateView(viewProperty, value);
 }
Example #10
0
        /// <summary>
        /// Call InitializeBindings() in the ViewDidLoad method of a derived view class to create the data bindings and update the view with the current view model values.
        /// </summary>
        /// <param name="rootView">The view that should display the viewModel</param>
        /// <param name="viewModel">The view model</param>
        /// <param name="bindingsParameters">Optional binding parameters; use to override default parameter values for specific bindings, or as an alternative for specifying binding parameters in the view tag attribute in AXML. Note that any binding parameters specified in the tag attribute wil override bindingsParameters.</param>
        /// <param name="idPrefix">The name prefix used to match view Id to property name. Default value is the root view class name + "_"</param>
        protected void InitializeBindings(UIView rootView, ViewModelBase viewModel, BindingParameters[] bindingsParameters = null, string idPrefix = null)
        {
            Bindings = new ViewDataBindings(viewModel, idPrefix ?? this.GetType().Name + "_", this);
            this.viewModel = viewModel;

            EnsureHandlersAreAdded();

            Bindings.AddBindings(bindingsParameters, rootView, NavigationItem);
        }
Example #11
0
 /// <summary>
 /// Override this method in a derived view class to change how a data-bound value is set for specific views
 /// </summary>
 /// <param name="view"></param>
 /// <param name="value"></param>
 public virtual void UpdateView(UIView view, object value)
 {
     ViewDataBindings.UpdateView(view, value);
 }