in

ExpressionBlog.com

Microsoft Expression Studio Community

This Blog

Syndication

Mirrored Blogs

Browse by Tags

All Tags » Composite WPF (RSS)
  • More MEF Samples and launch of MEF contrib.

    The past few weeks, the momentum has picked up around samples using MEF. In my last post I mentioned a few. Now today two great posts. First, Brad A (my awesome boss) has gone and done a really nice MEF 101 post . Kudos to Brad for finding the time out of his ultra busy schedule to play with MEF, and for delivering this nice easily digestible sample! Just when you thought you had your fill for MEF for one day, Bill Kratchovil goes and does a post on using MEF and Prism. For me this was a double gift as those are the two sweet spots in my heart.  Not only that, but he's gone and created MEF Contrib . I love to see it when the community takes the bull by the horns with these contrib projects. I am looking forward to the work Bill and others (yes I am talking to you) add to this. Good times!
  • MSDN Article on "Prism" went to press

    A few months ago I wrote an MSDN article on the new Composite Application Guidance (which will always be Prism to me :) ) which was just published. In the article I talk about Composite Applications in WPF in general, several design patterns in play, and specific ways to leverage WPF in doing so. I cover the essential components of the guidance, as well as how to use them in your apps. Oh and just for the record , I didn't copy the documentation, though I did write most of the overview content in it ;-) In the same magazine, you'll also find a great article by Brian Noyes where he does a deep dive into how Routed Events and Commanding work under the hood. It was fantastic having Brian on the team as we built Prism. His experience was key to our delivering a solid offering. If your evaluating whether or not Prism is right for you, or if you want some general insights on building Composite Applications then check it out. This includes if your looking to build on Silverlight, as p&p is currently in the trenches working on Prism 2.0 ! And if they are in the trenches you can be confident it will ship ;) Writing this article was somewhat of a dream come true for me. Years ago I thought about becoming a technical author. At the time I had a key technology role in an enterprise software shop. My CEO convinced me it was the "wrong" way to go and I would never be happy, which in my naivety I believed. I now know he was just doing some smart management reverse psychology :-) Anyway, when the opportunity came from Howard to fulfill some small aspect of this dream, I jumped at the chance. It was a terrific experience, though it had its share of late night stresses. Particularly because I was working on it while I was supposed to be on vacation. I hope to do more articles in the future. Let me know what worked and what didn't. Oh and let me send a shout out to my homies in my old team in p&p!
  • Firing generic events with EventAggregator

    It's been a while since i posted anything on Prism. When I left p&p, i said you would see more posts on Prism on my blog. I've been pretty immersed in MEF since leaving and haven't done any posts on Prism yet. Today, I got inspired (albeit late in the evening) based on a post on the forums to actually do that, so here I am :-). The post was from TSChaena about using EventAggregator to fire generic events similar to the way we did things with EventBroker in CAB. Using EventBroker allows you to dynamically define events in your application that are identified through a topic name rather than needing to define a strongly typed class as you do with the EventAggregator. There are several advantages to not using the approach in EB which I have identified in this post . However, there are times when you want to do a dynamic eventing system. The good news is that there actually is a solution for doing this with our EventAggreator though it is not exactly the same as the way we did it in EB. CompositeWPFEvent Before we look at the solution I came up with, lets talk quickly about CompositeWPFEvent. CompositeWPFEvent is a generic class that contains one type parameter TPayload. TPayload defines the payload that will be passed into the event when it is fired. The subscriber also uses the payload to provide filters for the subscription. For example if TPayload is a FundOrder as in the EventAggregator QuickStart, then you can supply a lambda such as fundOrder=>fundOrder.CustomeriD == customerID for example to filter on only events that are received for a specific customer. The common pattern you will see for defining such events is to create a class that inherits from CompositeWPFEvent for each event that is typed to the specific paramers. For example below is the definition for the FundOrderAdded event. public class FundOrderAdded : CompositeWpfEvent<FundOrderAdded> {} This event is then retrieved from the EventAggregator by calling the GetEvent method passing FundOrderAdded as the event. Now, although this is the common pattern, there is nothing about the EventAggregator that requires you to create a new event class for each event. CompositeWPFEvent is not an abstract class, so you can simply "use" it as you will, even in a generic case. For example you can do the following. 1: public class ThrowsEvents { 2: public ThrowsEvents(IEventAggregator eventAgg) { 3: eventAgg.GetEvent<CompositeWPFEvent< string >>().Publish( "SomethingEvent" ) 4: eventAgg.GetEvent<CompositeWPFEvent< string >>().Publish( "SomethingElseEvent" ) 5: } 6: } 7: 8: public class HandlesEvents { 9: public HandlesEvents(IEventAggregator eventAgg) { 10: CompositeWPFEvent genericEvent = eventAgg.GetEvent<CompositeWPFEvent< string >>(); 11: genericEvent.Subscribe(action=>Console.WriteLine( "SomethingEvent fired" , ThreadOption.UIThread, 12: false , e=>e == "SomethingEvent" ); 13: genericEvent...
Powered by Community Server (Commercial Edition), by Telligent Systems