This project is read-only.

FireFly is ViewModel framework oriented to working with hierarchically-organized data.

It’s simple in use…

Library contains less than 15 types, and you can learn how to use it less than 1 hour! Also, integration of FireFly with you application is very simple. Just create new subclass of ViewModelService and set its instance as value of ViewModelService.Instance, before framework will be used.

…”simple” – doesn’t mean “trivial”

FireFly provides powerful functionality which will be described below. And it can be easy customized for you needs.

Collection of view models – is a view model too…

FireFly framework already have class for wrapping models collections – CollectionViewModel. And these collections – are view models too. Once you define collection view model, you don’t need to worry about synchronization between model collection and its view model. CollectionViewModel will do it automatically!

…and it can have user friendly visibility behavior

I call it “user friendly collections”. It’s mechanism for determining visibility of the collection view model in visual tree depends on collection state. For example, if collection doesn’t have any children, it can be hidden and doesn’t appear to user. But if some element will be added to this collection, it will appear again.

Static commanding makes writing unit tests easier

View models in FireFly contains commands as static fields in most cases. For example:

#region CloseProjectCommand
        public IRelayCommand CloseProjectCommand { get { return _CloseProjectCommand; } }
        static RelayCommand<MainWindowViewModel> _CloseProjectCommand = new EditCommand<MainWindowViewModel>(context =>
            if(context.ViewModel.Project == null)
            context.ViewModel.Project = null;
            context.AppContext.Tree.ItemsSource = null;
        }, "MainWindowViewModel.CloseProjectCommand");

This approach makes writing unit tests for commands with rich UI logic a little easier.
Execute() and CanExecute() methods of RelayCommand takes CommandExecutionContext as parameter. Execution context have all information that command need for execution. All communication between command logic and application going through value of CommandExecutionContext.UIContext property. You can share same interface, for example IUIContext, between application and test environment.
Also, it makes view model a little more lightweight. In many cases your view model will have only link to model and links to collections (if it has) and no matter how much commands it supports.

And bonus

ViewModelBase, CollectionViewModel and RelayCommand already have Icon and DisplayName properties that you can use for binding. All you need is override ViewModelService.GetIcon() and ViewModelService.GetString() methods. Also, HierarchicalViewModel implement RemoveCommand with common deleting scenario.


Samples of using FireFly you can find in XAMLStylePad project.

Last edited Aug 4, 2010 at 12:25 AM by seoriy, version 40