Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9193889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:16:21+00:00 2026-06-17T21:16:21+00:00

This is a follow up of the post about MvvmCross Android Dialog Bing Programmatically

  • 0

This is a follow up of the post about MvvmCross Android Dialog Bing Programmatically

I’ve implemented the bindings of a Dialog in a Droid project:

    this.Root = new RootElement("Customer Info")
    {
        new Section("Private Configuration")
        {
            new EntryElement("Pin:").Bind(this, "{'Value':{'Path':'Configuration.Pin'}}"),
            new EntryElement("Name:").Bind(this, "{'Value':{'Path':'Configuration.Name', 'Mode':'TwoWay'}}"),
        };
    };

I’ve added the TwoWay in the Configuration.Name bind just for test purposes.

The problem now is that the bind is working only in OneWay. The object is not updated if I change something in the view, but the view is notified if the object is changed. This happens in both binds described above (with or without TwoWay in bind Mode).

This is the only thing left to have a full Droid.Dialog project, working with bind and multiple views, controlled by viewModels, using MvvmCross framework.

From what I’ve been able to debug (only Droid code and no PCL, in VS2010), every time I change the text in the EntryElement, the OnTextChanged method is called and the property Value is beeing updated.

EntryElement.cs

    public virtual void OnTextChanged(string newText)
    {
        //Log.Info("Just playing","New text:" + newText);
        OnUserValueChanged(newText);
    }

ValueElement.cs

    protected void OnUserValueChanged(TValueType newValue)
    {
        Value = newValue;
        FireValueChanged();
    }

    protected virtual void FireValueChanged()
    {
        var handler = ValueChanged;
        if (handler != null)
            handler(this, EventArgs.Empty);
    }

Here’s the code I have in core and droid projects

CORE

BaseViewModel.cs

    public class BaseViewModel : MvxViewModel, IMvxServiceConsumer
    {
        protected IConfigurationDataStore ConfigDataStore
        {
            get
            {
                if (_configDataStore == null)
                    _configDataStore = this.GetService<IConfigurationDataStore>();

                return _configDataStore;
            }
        }
        private IConfigurationDataStore _configDataStore;
    }

EditConfigurationViewModel.cs

    public class EditConfigurationViewModel : BaseViewModel, IEditConfigurationViewModel
    {
        public ConfigurationSet Configuration
        {
            get { return _configuration; }
            set
            {
                if (_configuration != value)
                {
                    _configuration = value;
                    RaisePropertyChanged(() => Configuration);
                }
            }
        }
        private ConfigurationSet _configuration;

        public EditConfigurationViewModel(string id)
        {
            Guid value;
            if (string.IsNullOrEmpty(id) || !Guid.TryParse(id, out value))
            {
                Configuration = new ConfigurationSet();
            }
            else
            {
                Configuration = ConfigDataStore.GetConfiguration(value);
            }
        }

        public void SaveConfiguration()
        {
            ConfigDataStore.UpdateConfiguration(Configuration);
        }
    }

ConfigurationSet.cs

    public class ConfigurationSet : MvxNotifyPropertyChanged
    {
        public string Pin
        {
            get { return _pin; }
            set
            {
                if (_pin != value)
                {
                    _pin = value;
                    RaisePropertyChanged(() => Pin);
                }
            }
        }
        private string _pin;

        public string Name
        {
            get { return _name; }
            set
            {
                //if (_name != value)
                //{
                    _name = value;
                    RaisePropertyChanged(()=> Name);
                //}
            }
        }
        private string _name;

        public string PrivateDescription
        {
            get { return _privateDescription; }
            set
            {
                if (_privateDescription != value)
                {
                    _privateDescription = value;
                    RaisePropertyChanged(() => PrivateDescription);
                }
            }
        }
        private string _privateDescription;
    }

DROID

EditConfigurationView

    public class EditConfigurationView : MvxBindingDialogActivityView<EditConfigurationViewModel>, IMvxServiceConsumer
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            DroidResources.Initialise(typeof(Resource.Layout));

            Root = new RootElement()
                {
                    new Section("Private Configuration")
                    {
                        new EntryElement("Pin:").Bind(this, "{'Value':{'Path':'Configuration.Pin'}}"),
                        new EntryElement("Name:").Bind(this, "{'Value':{'Path':'Configuration.Name'}}"),
                        new EntryElement("Description:").Bind(this, "{'Value':{'Path':'Configuration.PrivateDescription'}}")
                    }
                };
        }

        public override void OnBackPressed()
        {
            ViewModel.SaveConfiguration();

            base.OnBackPressed();
        }

        protected override void OnViewModelSet()
        {

        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:16:22+00:00Added an answer on June 17, 2026 at 9:16 pm

    Second answer after seeing your repo on https://github.com/zleao/MvvmCross.Dialog


    Thanks for the additional information.

    I’ve not run your sample yet, but seeing the simple code to reproduce the problem helps a lot.

    I think the problem is probably in your Setup file – https://github.com/zleao/MvvmCross.Dialog/blob/master/MvvmCross.Dialog.UI.Droid/Setup.cs

    The Setup there inherits from MvxBaseAndroidBindingSetup which is the base setup class for everything in Cirrious.MvvmCross.Binding.Droid and which itself inherits from MvxBaseAndroidSetup from Cirrious.MvvmCross.Droid

    Since you are using the Dialog code in addition to “just Binding” then you need to take your setup further – you need to add MvxBaseAndroidDialogBindingSetup from Cirrious.MvvmCross.Dialog.Droid. This class adds a number of important steps including registering a two-way binding for Value on all ValueElement instances – see:

        protected override void FillTargetFactories(
            Cirrious.MvvmCross.Binding.Interfaces.Bindings.Target.Construction.IMvxTargetBindingFactoryRegistry registry)
        {
            registry.RegisterFactory(new MvxPropertyInfoTargetBindingFactory(typeof (ValueElement), "Value",
                                                                             (element, propertyInfo) =>
                                                                             new MvxElementValueTargetBinding(element,
                                                                                                              propertyInfo)));
            base.FillTargetFactories(registry);
        }
    

    in https://github.com/slodge/MvvmCross/blob/vnext/Cirrious/Cirrious.MvvmCross.Dialog.Droid/MvxBaseAndroidDialogBindingSetup.cs


    So – to try to fix the problem, try inheriting Setup from MvxBaseAndroidDialogBindingSetup


    For more info about the layers of MvvmCross, please see http://slodge.blogspot.co.uk/2012/12/a-short-guide-to-layers-of-mvvmcross.html


    I hope this helps and solves the problem.

    Thanks for the excellent level of detail supplied.

    Please do note, though, that the Droid.Dialog code is still quite young compared to the Touch Dialog code – so you may hit genuine bugs and problems along the way. When you hit them, please do ask question here, or if they are bugs, then please do log them on Issues on https://github.com/slodge/MvvmCross/issues?state=open

    Stuart

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This post if a follow-up question to mt previous post: Android RESTful Web application
This is really a follow-up to my post about a Python oauth2 BaseHTTPServer conflicting
This is kind of a follow to my other post about Unity (http://stackoverflow.com/questions/3998559/irepository-iservice-unity-in-an-asp-net-mvc-application-reference-question). Basically
This is a follow-on question from my post about How to Encrypt mp3 Files
I was trying to follow the answer provided by this post About Event_calendar.Showing only
This is a follow up to my previous question about using XMLHttpRequest() to post
This is a follow up post of my previous question about BASIC auth over
I am tring to follow this post post and combine it with the ShootThemUp
I'm trying to follow this tutorial using StructureMap : http://iridescence.no/post/Constructor-Injection-for-ASPNET-MVC-Action-Filters.aspx What I'm trying to
This is a follow up of this [post] Ada: Adding an exception in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.