Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Prism & Silverlight: Part 10 - A Larger Example - "Email Client"

Download

Right click “Save as…”

  • WMV (WMV Video)
  • MP3 (Audio only)
  • MP4 (iPhone, Android)
  • Mid Quality WMV (Lo-band, Mobile)

This is part 10 of a series of screencasts illustrating some of the ideas found in "Prism" or the "Composite Application Guidance" from the Patterns and Practices team that can be used to build Silverlight applications in a way that lends itself to testability and modularity.

In talking to customers building business applications with Silverlight I find that Prism (and it's friend Unity) is frequently mentioned but not everyone has seen it and so I thought I would explore it myself and capture some of the results of that exploration here.

We start off with some fairly basic code which we move towards making use of dependency injection and modularity;

and then we move that code into the Silverlight world and try to illustrate some specific areas of Prism;

and then finally we try and bring some of these concepts together in a longer, more realistic example of a simple Email application built using the Prism framework - warning, this is a much longer session but I wanted something that draws things together;

The recommendation would be that you watch the 10 screencasts in order but if that feels like too long a process or if you're already very familiar with concepts like dependency injection and containers like Unity then perhaps watch the last screencast first and then refer back to the previous screencasts if certain areas need more illumination.

I put the source code for Video 10 here for download as it's a bigger set of source and something you might want to explore after the video - this does not necessarily represent "best practise" but is, instead, just meant to illustrate some of the Prism ideas.

Tags:

Follow the Discussion

  • It seems that all iPod versions of the videos in this series are copies of the first part ...

  • This is the good stuff.  I've previously used Prism in conjunction with Unity to create composite WPF clients in this manner, but it's useful to see a run through of the whole process (disclaimer .. I watched the first 40 minutes or so .. will continue with it tonight).  It's tackled at a refreshingly rapid pace whilst remaining clear and entirely comprehensible too.  Bravo.

     

    (Apologies .. I added this comment to the Part 1 comments section .. it was supposed to be here)

  • Mike Taultymtaulty Mike Taulty

    Thanks Kevin - glad you're finding it useful. To be honest, my original intent was that this would last around 30 minutes but it took me a good 2 hours to get to the point where I'd actually got something done which covered the various things I wanted to try and get in.

     

    I hope the rest of your watching goes as well as the first half Smiley

  • A really excellent set of videos Mike. I signed-up just to say that!

  • Mike Taultymtaulty Mike Taulty

    Thanks Pete - glad to have you signed up and thanks for the feedback.

  • Hi Mike

     

    Great videos!

     

    I tried downloading Part 1-10 in iPod format. It seems that they are all copies of Part 1 :/

     

  • Hi, I keep getting "Media Failure" errors when watching in Silverlight. If I right click and "Save Target As" on the WMV it downloads about 10% then I get a "Connection was closed remotely" error. I'm in the UK if that has any relevance - perhaps this needs a mirror copy?

  • Hiya Mike,

     

    Really a wonderful set of videos.  I'm on the other side of the world in Hawaii.

     

    I am also having Part 10 give me a media error about 85% of the way through.

     

    Thanks!

  • Mike Taultymtaulty Mike Taulty

    Apologies if you're seeing media errors - I'll ping the Channel9 guys and see if there's something we can do here. I'll also download the video again myself and see if I see the same problem.

  • IanBlackburnIanBlackburn mmmm coffee...

    Hi Mike,

     

    At around 30 minues you go and create your own commands for ListBoxSelectionChanged and TreeViewSelectionChanged - what are your opinions on using, for example, a TwoWay Binding to the ListBox SelectedItem property to the view model instead and then publish the event in the Setter?  Not such a nice solution perhaps but possibly easier in many of these cases.  Here's what I did for the MailListViewModel which seems to work fine:

     

    Adding a binding as follows:

    <ListBox SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
     ScrollViewer.HorizontalScrollBarVisibility="Hidden" 
    ItemsSource="{Binding Emails}">

     

    Then had the following property on the view model:

     

    private object _selectedItem=null; 
    public object SelectedItem { 
       get { return _selectedItem; } 
       set { 
            _selectedItem = value; 
            EmailSelectionChangedEvent evt = eventAggregator.GetEvent<EmailSelectionChangedEvent>();
    
            MailViewModel viewModel = (MailViewModel)value; 
            evt.Publish(viewModel == null ? null : viewModel.Email); 
           } 
    }
    

     

    Can you see any problems with this approach?

  • IanBlackburnIanBlackburn mmmm coffee...

    One other thought - you use converters in some of the views - I know that some MVVM guys think that you should never need a converter in the View since the ViewModel should prepare the data correctly for it.  I also know there are lots of discussions about MVVM currently and nothing really baked into the framework or tools to answer all the current questions - but just wondered what your opinion was.

     

    Fantastic set of videos by the way - really detailed and incredibly useful - many thanks for the work you have put into them; I for one really appreciate the hands-on "live code" approach that you take...

     

    Cheers

     

    Ian

  • Mike Taultymtaulty Mike Taulty

    Hi Ian,

     

    Nice to hear from you ( and see you briefly at the StackOverflow day the other week Smiley ). I agree that creating the custom command here did a feel bit heavy handed as it's quite a lot of code for what you get out of it although it does keep that separation very "pure". Someone dropped me a mail saying "What if I used Expression's behavior library for that?" which seemed like another approach and you have another one here  which seems pretty reasonable to me ( and a lot less code Smiley ).

     

    Thanks,

     

    Mike.

  • Nice screencasts, very well explained, a great start to learn how to use Prism and Unity.

    Bravo!

     

    Is it possible to have the code source from all samples, like you did for the last sample?

    (In order to play with).

     

    Thomas.

  • Hi Mike

     

    It's very easy to learn Prism with your screencasts. Thank you very much.

     

    Do you plan to add a part 11, about the topic unit testing? Currently, I'm not sure how to unit tests the different assemblies from the email client. Do I need a bootstrapper in my unit test method and the region manager stuff to get it run for the unit testing?

     

    Thanks in advance,

    Beat Kiener

  • You've made it much easier for me to understand the concepts because of the attention to detail that goes into them, also how each video builds upon the previous one in the series. Only feedback would be to include either the source or configuration files at the least as it can be a bit tricky to read them from the video.

     

    Thanks Mike!

  •  Hello,

               I have gone through the video you have mentioned.

               Although many doubt regarding EventAggregator, UnityContainer, RegionManager where solved. But I am failed to get a Answer Regarding:

            In my project I have  to Navigate as if   "Shell"    conatin two region ToolBar +( (Common Module(LoginViews))--------> Module A or Module B or Module C)

     

            Here "Common Module" Can be Considered as "login module". After login the user will choose the application namely "Module A" or "Module B" or  "Module c".     Each module as number of  "sub-Module" say "View"s Expect  for "login Module" .Please help with an Idea.

     

           my  shell .Xaml code:

    <UserControl x:Class="Forte.UI.Shell.Page"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
        xmlns:Regions="clr-namespace:Microsoft.Practices.Composite.Presentation.Regions;assembly=Microsoft.Practices.Composite.Presentation.Silverlight"
        xmlns:controls="clr-namespace:Blacklight.Silverlight.Controls;assembly=Blacklight.Silverlight.Controls">
        <Grid x:Name="LayoutRoot" HorizontalAlignment="Center" ShowGridLines="False">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
           <ItemsControl x:Name="MainToolbarRegion"
                         Regions:RegionManager.RegionName="MainToolbarRegion"/> --------------->This region contains "Menu"  it will not change   

            <Grid Margin="5,135,5,0" HorizontalAlignment="Center" VerticalAlignment="Center">     
                <controls:ClippingBorder x:Name="MainRegion"              ---------->This region load all module's view at present
                                         HorizontalAlignment="Center" 
                                         BorderThickness="0" CornerRadius="10" ClipContent="True"
                                         Visibility="Visible"/>                 
            </Grid>
        </Grid>
    </UserControl>

     

  • Hi Mike,

     

    First of all, This is a great series post, I must say.

     

    I am sure by now you are moved on to lot of new stuff like Silverlight 4 etc.

     

    I have seen this series of posts and its immensely useful for someone to start getting insight into PRISM framework.

    in my new project, I am trying to use PRSIM framework and want to have multi platform application.. ( that's the goal )

     

    I was wondering, If you can post this application or parts of last series of smaller posts which shows "Test Driven Development using PRISM" , "Test first" approach.

     

    That will give even more idea for new people trying to learn PRSIM, what to test and what not to test.

     

    your comments are welcome.

     

    Hope that would be possible.

     

    Cheers.

    hitesh.

  • Thanks for the great videos Mike - they removed the final hurdle to my adoption of Prism!

     

    Imagine my disappointment though when, at about 123 minutes of the last video, I got a "media failed" error ... oh well, at least I have the source code :/

     

    Maybe the wmv or whatever could be made downloadable?

     

    Anyways, really enjoys the series and got a lot out of it - cheers!

  • Mike Taultymtaulty Mike Taulty

    kurtmang - the video should be downloadable? try the little windows icon near to the "media downloads" text - that should let you download the video and pick up from where it failed for you ( apologies for that - I've no idea why the streaming version is failing here ).

     

    Mike.

  • Thanks Mike - didn't see that!

  • Great Video Mike,

     

    I followed through using VB and duplicated your efforts. It's starting to make sense for me now.

     

    Thanks.

  • Just... Thank you!

     

    This one is particulary great. The presentation is really good. I hope we'll got more and more Tongue Out

  • I don't have words to tell how great it is!! Amazing videos. These videos is the best tutorial I have ever seen.

    Mike thank you very much for this amazing job!

     

  • Hii Mike,

     

     I am  a beginner in Silverlight & Prism. I saw this vedio and i learned some concepts. I ve ended up with few questions..

    You have created many projects like "EmailEntities,EmailInterfaces,EmailService,MailListUI,MailReadingUI,MailSelectionUI,NewMailUI,

    PresentationUtility,ViewInjectionImplementation,ViewInjectionInterfaces".

     

    They are all related to UI  email functionalities. As a beginner, My questions are

     

    1. What is presentation pattern you have used in this sample..

         Pls explain me what are all the Models , Views , Presenters stuff used in the solution.. ?

    2. which class acts like a View , Model & Presenter ?

    3.If at all i need to include Database stuff(reading messages from DB) , I assume i need to have 2 other projects namely domain layer, infrastructure layer. In this context,  should the Model communicates Or View communicates Or Presenter communicates with the domain layer ?

     

    4. If i have domain & infrastructure layer, does it make sense to maintain the "PresentationUtility" project inside the infrastructure layer..?

     

    These are my fundamental questions awaiting your esteemed reply.

     

    Thanks

    Devasena

        

     

  • Hi Mike. Thanks for the great set of videos. You are a fantastic tutor.

  • Joe KahlJoe Kahl .NET Architect

    Mike,  Thank you for sharing.  You've done a great job of putting this technology together for us from the ground up.  I am finding your videos very helpful.  I have had the infamous "Part 10 Media Failure at 85%" twice in a row.  I would like to watch the entire Part 10 video.  Please try publishing the video again.  Joe

     

    So, the next day, from work, on a different computer I was able to watch the whole video.

  • Joe KahlJoe Kahl .NET Architect

    Mike,  I have downloaded your EmailClient solution.  I was able to get it to build after I built my own Prism assemblies.  When I run the app not much happens.  I get a blank browser.  You never mentioned the startup project.  From the video it looks to be the EmailClient.Web.  And with that selected my local web server starts up.  But there is nothing in the browser.  Here is the URL being opened:  http://localhost:51319/EmailClient.Web/  I have break points in the shell and bootstrapper, but they do not get called.  What have I missed?  Joe

  • Amazing tutorials Mike, thanks for sharing your technical expertise. I am new to SL and PRISM, but I found it really easy to understand and its very comprehensive. Kudos to you for such dedication.

  • Great video, has really helped me understand unity/prism better so I can decide how best to use it in my projects.

     

    Maybe minor question but in all your View's you always set the DataContext in a lamda which fires on the FrameworkElement.Loaded event.

     

    Is there a case when deferring this assignment until the Loaded event is better than just assigning immediately in the class constructor?

     

  • BlueguyBlueguy

    those tutorials were awsome,it was verrrrrrrrrrrrrrrrrrrrrrrrrrrry helpufil 4 me,thanks

  • It is most appresiaeted. I wonder if the devoleping team did se this. This is how it is done.

    Start with .. and then .. wonderfull.

    Now a days - Include the Wcf Ria Services with Prism - And show the last (show 10) again. Now ther is commands & behaviors.

    The one I want most, is how to use it on Model first approach. It seems to me using the model first approach, dictate a wrong way to use Prism 4 and Ria services?

    Is it Poco's or somthing else that is the starting point?

    Sskip

  • Mike, thank you very much for these great videos! You've really produced the best training material I've seen so far! Andreas

  • jkearsjkears

    For anyone who is remotely considering PRISM, I highly recommend that you watch all ten of Mikes videos, you will not be disappointed.
    I recently started to dig deeper into the adoption of PRISM 4.0 and prior to watching these videos I thought I truely understood all that I needed to get started, but truthfully I am so much further ahead as a result of  taking the time to watch all ten of these very well presented video tutorials.
    Mike does a fantastic job of articulating a good portion of what you need to know in order to roll with PRISM.
    Thanks Mike, job well done!
     
     

  • PeterPeter

    I really appreciated the videos and found them very useful. However, I converted the video 10 code to run with PRISM 4 but I also got the same problem that Joe  Kahl described above. Has anyone gotten this application to run using PRISM 4? It would be instructive for me if I can get it to run and use the debugger and see how PRISM/Unity are working.
    Thank you,Peter

  • GlemohGlemoh

    Nice work Amino acids Classification

  • bloodyguitarsbloodyguita​rs

    Excellent post Mike! Keep the good work...

  • bloodyguitarsbloodyguita​rs

    Excellent post Mike! Keep up the good work...

  • Hello Mike!
    I love your videos, I feel I got much wiser after watching this series.

    I think it would be a great thing if you could add videos about the other features of Prism 4.0 (navigation etc.)

    Also, I wish you could extend this series so that after watched and studied, user should be able to build a robust Silverlight LoB application, using other related features of Silverlight and its relatives, such as WCF RIA Services, Entity Framework, and patters like Repository, DAL and more.
    The final idea is to teach users how to create a real-life end-to-end LoB application using the most efficient available ways and technologies.

    Regards,
    Shimmy

Remove this comment

Remove this thread

close

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.