Prism and Blendability

23 views
Skip to first unread message

Corrado Cavalli

unread,
Jul 3, 2009, 7:06:09 AM7/3/09
to wpf-di...@googlegroups.com

For those who know Prism: How much Blendable is it?

I mean, once all infrastructure is up, can I get a preview of the result or I get final UI at runtime only?

 

Cheers,

Corrado

 

 

Shawn Wildermuth

unread,
Jul 3, 2009, 7:15:56 AM7/3/09
to wpf-di...@googlegroups.com

Its hard to get a view of the whole picture, but each view is very blendable.

 

Thanks,

 

Shawn Wildermuth

http://wildermuth.com

https://agilitrain.com

Microsoft MVP (C#), MCSD.NET, Author and Speaker

 

The Silverlight Tour is coming to a city near you!

Corrado Cavalli

unread,
Jul 3, 2009, 7:26:47 AM7/3/09
to wpf-di...@googlegroups.com

Better than nothing... J

Reading your article about Prism now… looks great!

 

Corrado

 

From: wpf-di...@googlegroups.com [mailto:wpf-di...@googlegroups.com] On Behalf Of Shawn Wildermuth
Sent: venerdì 3 luglio 2009 13:16
To: wpf-di...@googlegroups.com
Subject: [WPF Disciples] Re: Prism and Blendability

 

Its hard to get a view of the whole picture, but each view is very blendable.

 

Thanks,

 

Shawn Wildermuth

http://wildermuth.com

https://agilitrain.com

Microsoft MVP (C#), MCSD.NET, Author and Speaker

 

The Silverlight Tour is coming to a city near you!

 

From: wpf-di...@googlegroups.com [mailto:wpf-di...@googlegroups.com] On Behalf Of Corrado Cavalli
Sent: Friday, July 03, 2009 7:06 AM
To: wpf-di...@googlegroups.com
Subject: [WPF Disciples] Prism and Blendability

 

For those who know Prism: How much Blendable is it?

Shawn Wildermuth

unread,
Jul 3, 2009, 11:42:24 AM7/3/09
to wpf-di...@googlegroups.com

Thanks…

Michael Sync

unread,
Jul 3, 2009, 12:51:16 PM7/3/09
to wpf-di...@googlegroups.com
I think it's about user control, content control or data template. I don't think it's something to do with Prism. You can view User Control, Content Control and Data Template (if you are using MVVM with data template in Prism) in Blend. But you need to go to Resource to view the data template. you cant view DT  (Resource Dictionary) in VS. 
--
Don't go the way life takes you.
Take life the way you go

http://michaelsync.net

Corrado Cavalli

unread,
Jul 3, 2009, 1:23:39 PM7/3/09
to wpf-di...@googlegroups.com

I have a couple of question for all Prism gurus here… J

 

1)

As you know Blendability works when you add an instance of the Viewmodel to Resources section of your Window/UserControl/Page etc…, something that could also be done in Prism but if you need to use EventAggregator (something that very common I presume…) AFAIK you can’t since you have to “Inject” it into ViewModel.

I had a look at Shawn’s sample and he uses the “Marry” approach to associate a DataContext to a view, but this for me means “No Blendability”.

Did I miss something?

 

2)

What is you experience of unit testing on Prism apps? With all this IOC/Modules dependenciesis unit testing considered by Prism architecture? (I haven’t read all Prism details yet)

 

Thanks

Corrado

 

From: wpf-di...@googlegroups.com [mailto:wpf-di...@googlegroups.com] On Behalf Of Michael Sync
Sent: venerdì 3 luglio 2009 18:51
To: wpf-di...@googlegroups.com
Subject: [WPF Disciples] Re: Prism and Blendability

 

I think it's about user control, content control or data template. I don't think it's something to do with Prism. You can view User Control, Content Control and Data Template (if you are using MVVM with data template in Prism) in Blend. But you need to go to Resource to view the data template. you cant view DT  (Resource Dictionary) in VS. 

On Fri, Jul 3, 2009 at 7:06 PM, Corrado Cavalli <corrado...@gmail.com> wrote:

Shawn Wildermuth

unread,
Jul 3, 2009, 1:32:52 PM7/3/09
to wpf-di...@googlegroups.com

Actually, one of the benefits of composition is simplified testing as you can test the modules independently instead of only at the integration level.  I have pitched a testing article, but its been shelved for MSDN, I am actively looking for another publisher for that article…so keep your eyes out for it.

 

As for Blendibility, I think there is a disconnect with whether you want a design-time versus runtime data.  The injection method allows you to handle this on the XAML level if you want and then override it later. Its not perfect, but in my opinion the sample data approach is probably better (in the Blend 3 story) than trying to get your real model to be blendable.

 

Thanks,

 

Shawn Wildermuth

http://wildermuth.com

https://agilitrain.com

Microsoft MVP (C#), MCSD.NET, Author and Speaker

 

The Silverlight Tour is coming to a city near you!

 

Michael Sync

unread,
Jul 3, 2009, 1:35:59 PM7/3/09
to wpf-di...@googlegroups.com
1. 

If you are using Prism, you will need to register the interface of your view and actual view (you can also register IVM and VM too) in Unity Container or any other container that you choose. 

For example: 

container.Register<IMyView,MyView>(); or container.RegisterInstance

After that, you need to set the VM to DataContext of View instead of putting the instance in XAML. The reason is that the instance of VM should come from container. If you look at the sample from Prism, they linked the V and VM from code ( setting it manually, or Constructor Injection )

For example: 

var view = container.Resolve<IMyView>();
view.DataContext = container.Resolve<VM>();

or 

public MyView<VM vm){
  this.DataContext = vm;
}


There is some possibilities that you can get the instance of VM from container in XAML but it's not very straige forward.  I'm planning to play this since a few weeks but I couldn't get enough time to take a look at this issue. 

2. We are not using any DI in our unit test. We either mock it or simply pass the instance of the object instead of Property Injection or Constructor Injection. 

Corrado Cavalli

unread,
Jul 3, 2009, 1:43:31 PM7/3/09
to wpf-di...@googlegroups.com

>Actually, one of the benefits of composition is simplified testing as you can test the modules independently instead of only at the integration >level.  I have pitched a testing article, but its been shelved for MSDN, I am actively looking for another publisher for that article…so keep your >eyes out for it.

Agree, but with all the Container/Module stuff I’m wondering how hard is to create a testing infrastructure (probably is easier than I think…)

 

>As for Blendibility, I think there is a disconnect with whether you want a design-time versus runtime data.  The injection method allows you to >handle this on the XAML level if you want and then override it later. Its not perfect, but in my opinion the sample data approach is probably >better (in the Blend 3 story) than trying to get your real model to be blendable.

 

So you would use both approaches? I mean something like:

 

<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

             xmlns:vm="clr-namespace:Test3.ViewModels"

             xmlns:commands="clr-namespace:Microsoft.Practices.Composite.Presentation.Commands;assembly=Microsoft.Practices.Composite.Presentation"

             x:Class="Test3.Views.LeftSideView"

             mc:Ignorable="d"

             d:DesignWidth="304"

             d:DesignHeight="248">

    <UserControl.Resources>

        <vm:LeftSideViewModel x:Key="vm" />

    </UserControl.Resources>

    <Grid x:Name="LayoutRoot"

          DataContext="{StaticResource vm}"

          Background="Red">

        <Button commands:Click.Command="{Binding ShowDetailsCommand}"

                Height="24"

                HorizontalAlignment="Left"

                Margin="24,8,0,0"

                VerticalAlignment="Top"

                Width="64"

                Content="Send" />

    </Grid>

</UserControl>

 

Whose   Datacontext is then overridden one using a “Marry” approach?

 

Thanks

Corrado

 

 

From: wpf-di...@googlegroups.com [mailto:wpf-di...@googlegroups.com] On Behalf Of Shawn Wildermuth
Sent: venerdì 3 luglio 2009 19:33
To: wpf-di...@googlegroups.com
Subject: [WPF Disciples] Re: Prism and Blendability

 

Actually, one of the benefits of composition is simplified testing as you can test the modules independently instead of only at the integration level.  I have pitched a testing article, but its been shelved for MSDN, I am actively looking for another publisher for that article…so keep your eyes out for it.

 

As for Blendibility, I think there is a disconnect with whether you want a design-time versus runtime data.  The injection method allows you to handle this on the XAML level if you want and then override it later. Its not perfect, but in my opinion the sample data approach is probably better (in the Blend 3 story) than trying to get your real model to be blendable.

 

Thanks,

 

Shawn Wildermuth

http://wildermuth.com

https://agilitrain.com

Microsoft MVP (C#), MCSD.NET, Author and Speaker

 

The Silverlight Tour is coming to a city near you!

 

From: wpf-di...@googlegroups.com [mailto:wpf-di...@googlegroups.com] On Behalf Of Corrado Cavalli


Sent: Friday, July 03, 2009 1:24 PM

Shawn Wildermuth

unread,
Jul 3, 2009, 1:46:11 PM7/3/09
to wpf-di...@googlegroups.com

That’s one approach, or you can see Michael Sync’s post to this group (just happened a minute ago) and I like his approach as well.

Corrado Cavalli

unread,
Jul 3, 2009, 1:46:25 PM7/3/09
to wpf-di...@googlegroups.com

Thanks Michael, your answers blow away some of my doubts.

 

Corrado

 

From: wpf-di...@googlegroups.com [mailto:wpf-di...@googlegroups.com] On Behalf Of Michael Sync
Sent: venerdì 3 luglio 2009 19:36
To: wpf-di...@googlegroups.com
Subject: [WPF Disciples] Re: Prism and Blendability

 

1. 

 

If you are using Prism, you will need to register the interface of your view and actual view (you can also register IVM and VM too) in Unity Container or any other container that you choose. 

 

For example: 

 

container.Register<IMyView,MyView>(); or container.RegisterInstance

 

After that, you need to set the VM to DataContext of View instead of putting the instance in XAML. The reason is that the instance of VM should come from container. If you look at the sample from Prism, they linked the V and VM from code ( setting it manually, or Constructor Injection )

 

For example: 

 

var view = container.Resolve<IMyView>();

view.DataContext = container.Resolve<VM>();

 

or 

 

public MyView<VM vm){

  this.DataContext = vm;

}

 

 

There is some possibilities that you can get the instance of VM from container in XAML but it's not very straige forward.  I'm planning to play this since a few weeks but I couldn't get enough time to take a look at this issue. 

 

2. We are not using any DI in our unit test. We either mock it or simply pass the instance of the object instead of Property Injection or Constructor Injection. 

On Sat, Jul 4, 2009 at 1:23 AM, Corrado Cavalli <corrado...@gmail.com> wrote:

Reply all
Reply to author
Forward
0 new messages