WPF tuto’s – Forward commands

With the MVVM pattern, it’s quite difficult to handle context menu commands because context menu are not in the same tree view and we generally don’t want to bind on business commands that are in menu item view models. It’s the same problem for tool windows and so on, because we want to reuse the existing commands.

I describe below the “Forward” command pattern used in CBR. Note that MVVM is implemented via MVVMLight.

First, extend your ViewModelBase to have a ViewModelBaseExtended that will implement a ForwardCommand for all your view models. With also an overrideable method GetForwardCommandContext

CommandContext is an helper class that will contain the command to execute as string and an additional command parameter

#region ----------------COMMANDS----------------

private ICommand forwardCommand;
 public ICommand ForwardCommand
 {
 get
 {
    if (forwardCommand == null)
            forwardCommand = new RelayCommand<string>(
  delegate(string param)
  {
     Messenger.Default.Send<CommandContext>(GetForwardCommandContext(param),
           ViewModelBaseMessages.ContextCommand );
  },
  delegate(string param)
  {
    return CanForwardCommand(param);
  });
  return forwardCommand;
  }
 }

protected virtual CommandContext GetForwardCommandContext(string param)
 {
 return new CommandContext();
 }

protected virtual bool CanForwardCommand(string param)
 {
 return false;
 }

#endregion
 }

public class CommandContext
 {
 public string CommandName { get; set; }
 public object CommandParameter { get; set; }
 }

Continue reading “WPF tuto’s – Forward commands”

ComIko update

Hi,

A new version is under certification. It brings :

  • An improved parsing and refresh function.
  • A delete catalog command – take care there is no warning popup, but it moves in the system trash
  • PDF is now supported !

Good reading…

 

Bonjour à tous,

Une nouvelle version est en cours de certification. Cela apporte :

  • Une fonction améliorée d’analyse et de rafraîchissement.
  • Une commande de suppression de catalogue – attention, il n’y a pas de popup d’avertissement, mais il se déplace dans la corbeille du système
  • PDF est maintenant supporté!


Bonne lecture….

UWP : New C.B.R.

Hi all,

I am writing a new version of C.B.R for Universal Windows Platform. I start from the ground with a MS sample Lunch scheduler (https://github.com/Microsoft/Windows-appsample-lunch-scheduler) and hope this new version will be available under 2 or 3 months…

I will write a few articles about trouble i have with my solutions like customize the title bar and the full screen mode because it is quite hard to find help and tips about this new platform.

Improvments : I will do it like “Groove” : give a folder, and CBR will create catalogs and books for you. No more need to create everything by hand

Screenshots to come