Prism: INotifyPropertyChanged implementation usage with BindableBase

Did one of these 3 years back for Windows Phone 8.1 I guess.

Gist for this new one here.

Step 0 – In Visual Studio, start a new Blank App (Universal Windows)

Step 1 – In Visual Studio, install Prism.Windows

PM> Install-Package prism.Windows -Version 6.3

Note that doing this caused prism.Windows to appear in the project references.

Step 2 – to start off tidy, add folders View, Model, ViewModel to the project

Step 3 – create a viewmodel file(s) (e.g. MahVm.cs as below),  and follow the code below, noting that MahVm inherits from BindableBase (once you add in the using for Prism.Mvvm)


Commanding in Prism


In the screenshot below, the button is enabled because the text box does not contain ‘NO’:


In the screenshot below, the button is disabled because the text box does contain ‘NO’:


The comments in the code screenshots probably cover everything:




using System.Windows;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.ViewModel;
using System.Windows.Input;

namespace CommandImpl.ViewModel {

/// A basic test of the Prism implementations of Commanding, using DelegateCommand and NotificationObject.
/// Next steps are how to test this.

public class CommandViewModel : NotificationObject {

private ICommand _submitCommand;
public ICommand SubmitCommand {
get { return _submitCommand; }
set { if (_submitCommand == value) return;
_submitCommand = value;
RaisePropertyChanged(() => SubmitCommand);

public CommandViewModel() {
SubmitCommand = new DelegateCommand(Submit, CanSubmit);

public bool CanSubmit(string cmdParameter) {
if (cmdParameter == null) return true;
return !(cmdParameter.Contains(“NO”));

private static void Submit(string cmdParameter) {
// Although I only want the command parameter for the CanSubmit, it appears there is no ctor
// that takes no parameter for the Execute, but a parameter for the CanExecute
// The idea is possibly I guess that you pass-through the value to the CanExecute method.
// And the plus anyway is that if CanSubmit returns false, you never reach here anyway.
// But given that, it does mean that cmdParameter is always redundant, as you clearly do not invoke
// CanSubmit from here.
var msg = string.Format(“Value in textbox: [{0}]”, cmdParameter);
//msg = CanSubmit(cmdParameter) ? “Can execute” : “Cannot execute”;

The Prism Developer’s Guide

Ever seen this?


The manual is good and it’s free, and the full download comes with a ton of worked examples. This is the Prism 4 Guide, and this is the Prism 4.1 download, including the examples.

In fact here’s one I hadn’t noticed – a manual about Prism and Windows 8.1 – surely worth a browse.



And just searching for DelegateCommand references, just as a for instance…


Slightly tangentially, you can replace the RelayCommand references with Prism DelegateCommands, and everything continues to work:








The top row of Order 11088 is one I created using the Add button, edited to change the Freight value, and then used the Save button.

To prove it made its way to the database:


May 2015…

And now we have this


, and this


The date suggests I just missed it last time round. This looks good:


And I should back this up somewhere in case it disappears:


Argh… looks to be the same. But for (my) reference I’ve saved it to my Adobe cloud.

And a final link to the QuickStarts etc.

Diary of a reluctant gardener

So no direct evidence of me doing stuff, so you’ll just have to take my word for for it:


The work is replacing… anyway, it’s hard, it’s not my favourite thing, but once it’s all over, it will look nice.

I am aware that I have done zero music for some time now. But I haven’t been idle. I have my plan.

Anyway… Prism: Prism libraries implement the INotifyPropertyChanged etc and ICommand interfaces. For now, this is my cheatsheet for ICommand (right now, just an example of a by-hand implementation):

Office Lens_20140801_231330_processed (1)