开发者

How can i use MEF to partition my project into smaller xap and download them on the fly?

Right now, my XAP file has become big and i need a solution to partition it into some smaller applications. MEF or PRISM might fix my problem

I read and watch online tutorial for them but still have no clue how i can apply them to my current project.

Let me explain my project:

-In the mainpage.xaml, it only has ONE menucontrol . However, that menucontrol will be built DYnamically basing on the data retrieved through the service call. You can see on my Menu picture

http://www.flickr.com/photos/31396433@N08/sets/72157627077751863/

-Everytime a user click on a menuItem, a window of that menuItem will be pop-up to let the user doing business work. You can see on my GeneralLedger_JournalPosting picture. The journalPosting menuItem belong to the GeneralLedger section.

http://www.flickr.com/photos/31396433@N08/sets/72157627077751863/

This is the code of showing how i show the pop-up menuItem window through the click event of the menuItem on the menuControl

private void MenuItemClick(object sender, RadRoutedEventArgs args)
    {
        RadMenuItem item = args.OriginalSource as RadMenuItem;
        SFMenu sFMenu = item.Header as SFMenu;
        OpenMenuItemScreenBy(sFMenu.Name);

    }   

    private void OpenMenuItemScreenBy(string menuName)
    {
        if (menuName == "User Management")
        {
            var userManagement = new UserManagement();
            //userManagement.WindowStartupLocation = WindowStartupLocation.Manual;
            userManagement.Top = 50;

            userManagement.Show();
        }
        //Testing area
        else if (menuName == "Testing")
        {
            Testing t = new Testing();
            t.Top = 50;
            t.Show();
        }
        //
        ......
        .......

That's all about my project. Basically, i just need to create different screen for each of my menuItem. Because the number of my menuItems continue to increase so the more corresponding window screen should be created. And that makes my XAP become bigger.

Solution:

I am thinking a way to seperate each of my Window MenuItem screen (such as the GeneralLedger_JournalPosting) into seperate XAP. And my main XAP file will only contains the menuControl.

However, I need to know a way how to load my corresponding menuItem XAP file on the fly if the user click on a menuItem(for example GeneralLedger / JournalPosting). And open the JournalPosting screen

But if the user click on that menuItem again, then no download needed. Just look at on the cache

(I watch MEF tutorial and know that i need to use the DeloymentCatalog for the feature. However, i don't see any example to let us manually access through code the usercontrol in the dynamic XAP file)

Secondly,

Because each of my menuItem window screen will use the same third-party dll (for example: the dll for the GridView, Navigation,...). So can you also tell me how to let me only download those dll ONE time . Because if i put those dll into each of my menuItem window screen 开发者_Go百科XAP, then i think they will be redownloaded every time the corresponding XAP requested for downloading

thank you for your help.


have a look here: http://www.codeproject.com/KB/silverlight/MEFDynamicLoading.aspx. This project describes how to load xap's on demand and displaying them after downloading.

The interesting part for you is the MainPageModel.cs. There is the loading of the xap and putting the content into the panel.So if you ask the DeploymentCatalogService to "AddXap" and it is already loaded => call the callback or fire the event.

Regarding the dll's. You have to put them in your MainApp. In you downloaded app's you have to set the in the MainApp defined dll's to CopyLocal = false (It is found in the Properties of the dll (References))

I hope this helps!

BR,

TJ

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜