Microsoft Open House Summary – WPF 4 and Blend 4

November 14, 2010

4 comments

To all of you who participated in my WPF 4 and Blend 4 lecture at Microsoft Raanana today, it was my pleasure.

I hope that you enjoyed and learned one or two things new about WPF.

 

You can download the presentation and demo code from here.

Hope to see you soon.

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*

4 comments

  1. SaraganiNovember 17, 2010 ื‘ 15:53

    Hi,
    We have a problem and we are hoping that you have a solution or suggestion.

    We want to use MEF in out project. The “plugins” will actually be elements with different types.

    To make a small example, let’s assume that out program is a Paint software, and our elements derives from an abstract class called Shape.

    We would like to add more and more shapes to the Paint software just by adding more DLLs to the MEF/Catalog directory.
    For each shape a button will be created, so we can click on it in order to draw a new shape.

    Right now, if we have defined several types of ViewModels, we could have defined in our view that the default view for a ViewModel_X is View_X.

    For example:





    Now we don’t have this option any more.

    We would like to have a ViewModel that contains the list of the currently painted shapes and then the Main View would draw the shapes.

    This is off course just an example, but here are the questions:

    1) How to achieve the Binding to the list of shapes?
    My guess will be creating an ItemsControl that uses a Panel like Canvas.
    Is there any other solution?

    2) How can we have the Model, ViewModel and View of each Shape in the DLLs and have the MainUI draw the shapes other than doing for example RectangleViewModel.ToString() ??
    I was thinking of having the XAML/UserControl in the MetaData. Is this the right way?
    If not, what other solutions do I have?

    3) As you probably knows, MEF creates 1 instance of each the object in Catalog. This means that I can create only 1 Shape of each kind.

    Right now, the solution we are thinking of is to have the Shape have a function like “CreateNew” that will return a new instance of the object.

    Any other solution??

    Thanks

    Reply
  2. SaraganiNovember 18, 2010 ื‘ 09:15

    Hi, why wasn’t my previous comment/question approved?

    Reply
  3. Tomer ShamamNovember 18, 2010 ื‘ 21:04

    Hi Saragani,
    Your previous comment has been filtered as spam somehow, but I resurrected it ๐Ÿ˜‰

    As for your questions:
    1. You should have a collection of ViewModel in your “canvas” view-model with ImportMany MEF attribute on it. Just bind this property as your source of the ItemsContol.ItemsSource you should have in your โ€œcanvasโ€ view.

    2. You should create a triad in each DLL for each shape of course, and you should provide kind of service, for example: IResourceService which has AddResource method which merges your viewโ€™s DataTeplate with the application. Then WPF will use this resource DataTemplate automatically. There are other ways tooโ€ฆ

    3. In such case you should Export a shape factory class, not the shape itself. You should have a Create method of course which creates the shape ViewModel.

    Itโ€™s funny because Iโ€™ve architected a similar project with MEF and stuff one month agoโ€ฆ ๏Š
    Please feel free to ask should you want me to consult.

    Tomer

    Reply
  4. SaraganiNovember 18, 2010 ื‘ 22:50

    Ok, thanks. ๐Ÿ™‚

    Reply