Is there a standard way to convert UWP application that uses bindings currently, to use X:Bind?

29 Views Asked by At

The application is using mvvm as well as it can at the moment. Currently the application uses binding in every view. There is a basecontrol class that handles the propertychange currently and uses a global property (ParentProperty). When I try to convert a command to an event, this global property I have is null when the "event" method is hit, but not null when using a command flow with classic bindings. I've set the context in the code behind, and the clicking of the button reaches the method it needs to. It's just I have a property that isn't getting its values when trying to use xbind, over binding/commands.

For the most part I understand and see that xbind works with simple instances, but the event part of it has me scratching my head. The code below is a simple navigation event to another page, where we will be adding a new record. This code works fine using a command, but when trying to do x:bind, the parentproperty is null.

The one difference between the command and event is the Model model = new Model(); in the event method is Model model = obj as Model(); in the command. which takes in a object obj argument.

            AddEditView control = new AddEditView();
            control.ParentProperty = ParentProperty;
            Model model = new Model();
            if (Model == null)
            {
                Model = new Model () { };
            }
            Model.ParentPropertiesType = ParentProperty ;
            control.ModelDetailsForAddEdit = Model;
            control.PropertyChanged += ModelDetailsForAddEdit_PropertyChanged;
            Utility u = new Utility();
            NavigationUtility.ShowDetailPage(ParentProperty.Id, u.GetInitializedControl(control, ParentProperty, 0), "View", "Add View");
0

There are 0 best solutions below