Calling commands across the app domain boundary WPF

60 Views Asked by At

I'm working on an MVVM and AddIns-based application. I want to build the menu (ribbon control) dynamically through the AddIn module which will contain MVVM based assembly. On the host side, I'm unable to fire the command which is bound through ViewModel, which is hosted in separate appdomain from host application. How should I approach this issue of dynamic ribbon tabs generation with all bindings to commands/icons from the respective AddIn module.

Edit: I've developed an MVVM-based application. All application state and commands are in ViewModel and that is bound to the View, which works as expected. Afterwards, we write code using Managed Addin Framework (MAF) for .net and incorporated that application through it. The issue is coming that we are unable to generate a menu based on the commands in the Addin at the host side. I wrote a property to return menus from the ViewModel Addin to the host, but it just returns the plain objects and commands do not get propagated through AddIn Framework. Here is a code sample:

public IEnumerable<TabViewModel> MenuTabs
{
    get
    {
        var tab = new TabViewModel{ Header = "Tab 1"};
        var group = new GroupViewModel {Header = "Group 1"};
        var button = new ButtonViewModel{Content = "Say Hello", Command = HelloCommand};
        group.Buttons.Add(button);
        tab.Groups.Add(group);
        return new[] {tab};
    }
}

This code is written in say TestViewModel, and HelloCommand is an implementation of ICommand interface from WPF input library. The HelloCommand does not reach at the host side everything else is available and I'm getting Ribbon control's tabs and groups properly, but the commands are not being transmitted to the Addin Host.

Edit2 The issue is that, we want to show the Ribbon in the AddIn-Host window those buttons refer to the commands in AddIn's ViewModel, the final thing (i can) is to move the menu control to the AddIn too. Has someone encountered same problem and want to share the experience?

0

There are 0 best solutions below