This project is read-only.
Commands.CommandDictionary is a dynamic that allow you to specify different IScriptCommand in it.

New DynamicRelayCommandDictionary implementation

The class of dynamic is currently changed from DynamicDictionary<IScriptCommand> to DynamicRelayCommandDictionary, where the new one produce <name>Command RelayCommand when a IScriptCommand is set.

For examples,
CommandDictionary.Open = IOInitializeHelpers.FileList_Open_For_DiskBased_Items

creates :
CommandDictionary.OpenCommand RelayCommand, and you can use binding (e.g. {Binding Commands.CommandDictionary.OpenCommand}) to access it.

Please see the Test_DynamicRelayCommandDictionary demo for more information.

Current implementation

The current implementation does not use RelayCommand, instead, the CommandManager is IExportCommandBindings and it manually export the IScriptCommand to ScriptCommandBindings to the ViewModel, and the ViewModel responsible for registering the CommandBinding when OnViewAttached is triggered.

e.g. the FileListCommandManager would export this :
ScriptCommandBinding.FromScriptCommand(ApplicationCommands.Open, this, (ch) => ch.CommandDictionary.Open, ParameterDicConverter, ScriptBindingScope.Local),

And in FileListViewModel.OnViewAttached(), it register the command bindings using
Commands.RegisterCommand(uiEle, ScriptBindingScope.Local);

Local means registered in the sub-control, as the FileListViewModel is also an IExportCommandBindings, so if ScriptBindingScope set to Explorer or Application it will be registered in ExplorerViewModel or ApplicationViewModel.

Last edited Aug 8, 2014 at 7:31 AM by lycj, version 1

Comments

No comments yet.