Validating two usercontrols

Your next issue is that User Control won't respond meaningfully to, say, keyboard messages when it does have focus.

You'll need to detect clicks on the UC background to handle mouse messages, as well as override the painting so it is obvious to the user that the UC has the focus (use Control Paint. If this starts to sound unattractive, it's because UC was really meant to be a container control.

To unblock a file, right click on it, and select properties, and then select the ‘unblock’ button.

It needs to contain some kind of Navigation that shows the list of Page View Models, and clicking on a Page View Model should execute the Change Page command.

In addition, I added an s to Products View Model since it really deals with multiple products, not a single one.

An added advantage to having a View Model to control the application state is that it can also be used to handle other application-wide objects, such as Current User, or Error Messages.

The last thing to do is change to make Application View and Application View Model our startup, instead of Product View/Product View Model. You can download the source code for this sample from here.

Run the project and you should see something that looks like the images below, which quickly switches the Current Page when clicking on the Navigation buttons. Once you get more comfortable with WPF, I would recommend looking into using a Messaging System, such as MVVM Light’s Messenger, or Microsoft Prism’s Event Aggregator to broadcast Change Page commands from any View Model so you wouldn’t need to find the Application View Model to execute the Change Page Command, however that’s for another day.

Leave a Reply