A working project using nested regions in Prism4.0, TelerikTabControl, Silverlight 4.0

Thread is closed for posting
1 posts, 0 answers
  1. B4CD9118-B37C-4B33-B1A6-075BB052A992
    B4CD9118-B37C-4B33-B1A6-075BB052A992 avatar
    39 posts
    Member since:
    Feb 2010

    Posted 21 Sep 2010 Link to this post

    Requirements

    RadControls version v2.0.50727

     

    .NET version 4.0

     

    Visual Studio version
    VS 2010 Ultimate

     

    programming language
    C#

     

    browser support

    all browsers supported by RadControls


    PROJECT DESCRIPTION
    Many, many thanks to Miroslav from the Telerik team and Juliana Antonchik for great insights on the workings of SL and Prism.

    Summary:
    A sample project showing how to show nested regions inside a RadTabControl using Prism-Framework.

    Goal:
    1. Take a whole self-contained multi-module project with nested regions and import it into a RadTabControl.
    Result – with minimal code this is possible.
    2. Clarify who calls who in a Prism framework.
    Result – this has been clarified and described in the comments.
    3. Create a demo project using the absolutely bare minimum of code to prevent cluttering of “nice-to-have” functionality around the core functions.
    Up: Code is easy to read
    Down: Not an out-of-the box production grade project. More of an enhance-it-yourself type of project. Yet I think enhancing something that works should be an easy deal.

    Key places:
    Search for all comments where there is “//IMPORTANT” in the comment.

    How was the project created?
    1. Created a new Prism Silverlight 4.0 QuickStart Solution.
    2. Moved the ShellView XAML into Module-1 as RegionsView.XAML
    3. Created an new ShellView with a ribbon-bar and a RadTabControl.

    How was the project created?
    1. Created a new Prism Silverlight 4.0 QuickStart Solution.
    2. Moved the ShellView XAML into Module-1 as RegionsView.XAML
    3. Created a new ShellView with a ribbon-bar and a RadTabControl.

    How To Run?
     You have to have the latest Prism and Telerik for Silverlight. 
    Just unzip and Re-Build the solution in VS 2010. I double-checked, but if you get a missing project reference - all DLL’s are in the “Lib” directory.
     R-Click on the Web-Project – Set As Startup Project
     R-Click on Web.ShellTestPage.aspx – Set As Start Page
    At the start, when you get the prompt “Do you want to enable Silverlight debugging…”
     Click Yes:
     This ReadMe.PDF is included in the zip file.

    Included: Lib-directory ->All DLL’s.
    Deleted: *.user; All Bin-folders; All Obj-folders

    Remember: If you ever give a Silverlight project to somebody else or if you use SVN – make absolutely sure that you DO NOT send *.user files. This has the potential to block the ability to debug (debug points are not hit) and can cost hours of troubleshooting on the other end.

    Things to pay attention to:
    ShellView.XAML.CS has examples on how to handle click events in the ribbon:
    - Ribbon-Button; Default Click Event
    - Ribbon-Button; Your own custom Click-Event
    - TelerikTab; Close button
    ShellView.XAML has examples on how to:
    - Declare a ribbon with buttons  and a tab-region for accepting regions from other modules.
    - Exact syntax for adding the path to an image we want to display inside the Tab (Like the “X” for closing the tab)
    Search for “#region SomeUsefulNotUsedCode”
    See how the closing events are defined and subscribed to.
    See how the views in Module1 and Module2 are initialized differently.
    Check the Web.config for a sample connection string syntax
    Check the ShellView.XAML for a sample syntax on how to bind an image.

    Your responsibility for configuring RIA operations:
    WEB-Project - Properties
    Pay attention to what is included in the Silverlight-Applications tab of the project properties. When you include a module enable it for RIA.
    WEB-Project – Project Dependencies
    Pay attention to what is included in the dependencies.

    Disclaimer:
    This is a demo-project which is offered as-is. Use only to teach yourself during the first difficult weeks when entering Silverlight+Telerik+Prism4.0.

    Comments from Telerik:
    - When an application is built in a "standard"  modular way every little change in any of the modules means that the whole application needs to be rebuilt.

    - Therefore it is beneficial when we use Inversion of Control (IoC) pattern where the application does not depend on the modules but the modules depend on the application or part of it (the common dll in prism).

    - We use interfaces and event aggregators to represent abstract elements that the application depends on. They do not change very much once they are defined.

    - This though does not solve the problem how the modules are composed and used at runtime since the app in reality dependent on its modules even though we prefer this not to happen in our solution.

    - Composition frameworks are used to manage the complexity of different elements depending on others, the so-called "Dependency Injection".

    - By default prism uses ObjectBuilder but can also work with MEF.

    - In simple terms they map interfaces to types that implement them and can supply them on demand.

    - It is best if we let these frameworks construct our instances since they will resolve the dependencies (the IRegionManager) in your case. Thus we can request any dependency in our classes and we do not need to care about creating it or managing its lifespan.

    - MEF even allows re-composition which means it will track and update objects with newly added dependencies once it has constructed them (when using ImportyManyAttribute and AllowRecomposition=True).

    - Prism leverages composition frameworks and adds a few things that are nice to have in a real application.

    If you are interested in architecture / patterns there are many articles which discuss ways to resolve the same problem. A good article can be found here:
    http://martinfowler.com/articles/injection.html

     


Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.