Dependency registration in SimpleIoc, by default uses Lazy Instantiation, meaning the object won’t be created until it is requested, in this case, via the property on the ViewModelLocator class.
Due to configuring subscription of a message type in the Constructors of my ViewModels in MVVM Light I recently came across a situation whereby messages were being published prior to them having been subscribed to, meaning that the messages disappeared into the void unhandled. The ViewModels relating to the pages I had navigated to were available in the ServiceLocator, but the pages that I hadn’t navigated to were not being instantiated.
Continue reading “Eager Instantiation of ViewModels with MVVM Light Messaging”
It’s often necessary to “inform” other areas of an application of changes that have occurred. This can be achieved through Messaging. In the previous tutorial we created a Settings page and made the TranslationDirection Configurable. It would be nice if the Main View Model knew about our new Translation Direction setting, let’s look at how we can achieve this.
By the end of this tutorial we should have implemented a SettingsChangedMessage, subscribed to it from our MainViewModel and Published it from our SettingsViewModel. Continue reading “Universal App Tutorials Part 15 : MVVM Light Messaging”
Applications generally have a settings page, or similar allowing the user to configure the application. We laid the groundwork for making the Translation Direction setting configurable in the previous post, let’s look at putting that in to practice.
By the end of this tutorial we’ll have a really basic Settings Page, 2 Buttons allowing the user to pick between Morse to Alphabet and Alphabet to Morse, and a TextBlock displaying the current Translation Direction. Continue reading “Universal App Tutorials Part 14 : Settings Page”
One of the most compelling reasons to download an app is the number of Universal App Reviews in the store. This tutorial will look at adding a Review App Button to our completely empty About Page. There are various places you can surface the Review App Function, commonly it’ll be available on an About or Info page, or you may choose to have a Review Reminder. As with a number of things with UWP apps, the Universal App Review Method changed slightly from Windows Phone 8’s MarketPlaceTask, let’s take a look…
Continue reading “Universal App Tutorials Part 12 : Universal App Reviews”
One of the rules of using MVVM is that your model shouldn’t need to know anything about the UI Layer, and your View should be decoupled from the Model via the ViewModel. It can often be necessary to have some form of conversion between what our Model understands and what the View would understand. A common example would be converting a boolean flag to a Visibility State, this is where Value Converters come in.
We’ll follow a slightly more domain specific example in this case, converting the TranslationDirection Enumeration Property to a Visibility State for our Morse Input User Control.
Continue reading “Universal App Tutorials Part 11 : Value Converters”
Despite the rise in popularity of Single Page Applications (SPAs) and supporting frameworks like Angular in the Web Development world, it might be nice if we had more than one page in our app, or at least had the option to. Our app so far is contained within a single page, MainPage.xaml. A common pattern is to have different pages for Settings or Publisher contact information. Navigation has moved on since Windows Phone 7.5 when it was URI based, we will look at how it now works with Universal Apps with typing and the MVVM Light implementation of INavigationService. Continue reading “Universal App Tutorials Part 10 : MVVM Light NavigationService”
As we saw when we migrated our Universal Windows App to Windows 10 targetting Phones and PCs with the same set of markup presents us with a challenge…
This UI is less than usable! There are a new set of User Controls made available as part of Windows 10, for example the Relative Panel. In this post we’ll look at ways we can make our UI adaptive based on the screen size we are targeting.
By the end of this post we will have a single app that is usable on PCs, tablets, and Phones. We’ll be looking into Visual State Triggers in order to alter the size of the text presented in our Input and Output TextBox and TextBlock controls. Visual State Triggers apply transformations to the base XAML defined, we’ll be using this method to make our app responsive.
User controls offer a way to abstract common areas of your User Interface in a reusable package, allowing you to simplify your views and push some of the complexity of your UI into more manageable pieces. This tutorial will focus on Data Binding to Properties on a User Control from a ViewModel.
By the end of this post we should have a basic User Control bound against some Commands living in the MainViewModel to manipulate the content of the Input, in our case, we’ll offer a way to input Morse Code (dots/dashes) outside of needing to use a Keyboard in preparation for extending the App to translate both ways from the User Interface.
Continue reading “Morse Coder Part 7 : Data Binding User Controls”
The solution for my Morse Coder series of Universal App Tutorials is now available on GitHub:
Have a look if you’ve been following the tutorials or are just curious. I’ll be adding to this in alignment with the tutorials.
Hope it helps!
To date, we have a functional, but basic set of Windows Phone and Windows Store applications which can translate Alphabetical Input to Morse Code. One of the key tenets of MVVM Light is the ability to inject design time services or functionality to provide a better design experience. We need somewhere to store our Application Settings, along with a means of setting and retrieving them, we won’t cover the implementation of this, but we will cover the creation of our interface and the implementation of a design time settings class.
By the end of this post we will have, at design time, the ability to manipulate a settings class to be used with the designer in Visual Studio, or through Expression Blend. This will be done via an application settings interface detailing what data we need to store and of course what type it needs to be. As we are targeting multiple platforms, the interface, in a future post will be implemented to provide the storage of our settings per operating system.
One of the main benefits of using Dependency Injection to achieve this is that the implementation of our ViewModel is not concerned with where it retrieves information from and doesn’t need to make decisions depending on which context it is being ran in, this moves us closer to alignment with the Single Responsibility Principle.
Continue reading “Morse Coder Part 4 : Dependency Injection with MVVM Light SimpleIoc”