About UI Composition QuickStart

Topics: Prism v4 - Silverlight 4, Prism v4 - WPF 4
May 19, 2011 at 7:49 AM

Hey every one, 

I tried to go through the Silverlight only - Open QS - UI Composition QuickStart.bat example in the Prismv4, and i tried to do the same thing in WPF. 

I almost achieved the same thing in WPF, except one thing, that in EmployeeSummaryView.xaml, the tab item header's content is databound the sub-view's viewModel's "ViewName" property, in this way:

 

<prism:TabControlRegionAdapter.ItemContainerStyle>

<Style TargetType="sdk:TabItem">

 <Setter Property="HeaderTemplate">

<Setter.Value>

 <DataTemplate>

<TextBlock Text="{Binding ViewName}" /> </DataTemplate>

</Setter.Value>

</Setter>

</Style>

</prism:TabControlRegionAdapter.ItemContainerStyle>

 

However, this does not work in WPF. 

Could any one help me on this ?

Thanks a lot!

Developer
May 19, 2011 at 5:31 PM
Edited May 19, 2011 at 6:07 PM

Hi,

You might find the following threads useful, as they deal with the subject of showing a value in a tab item's header:

I hope you find this helpful.

Guido Leandro Maliandi
http://blogs.southworks.net/gmaliandi

May 20, 2011 at 8:33 AM

HI GuidoMaliandi,

Thanks a lot for your reply!

I went through the subjects and find it helpful.

 

However, there still things that i don't get.

1. in one the solution given in the subjects, i cound simply bind the "Header" property to "Content.DataContext.ViewName",

but here what is the "Content" ?

 

2. I still could not understnand why can i NOT do it the same way as in the Silverlight UIComposition quick start example ?

Thanks again!

Developer
May 20, 2011 at 7:49 PM

Hi,

When you bind to something inside a tab control's ItemContainerStyle, the "Content.DataContext.ViewName" indicates that you're binding to a property in the DataContext of the content of the tab, that is, the view added inside the tab item. That means that it binds to the ViewName property in the ViewModel of the view you're adding to the TabControl region.

As for your second concern, you should take into account that there are differences in Silverlight and WPF's TabControl. For example, in WPF, the TabControl inherits from Selector, while in Silverlight it doesn't. That differences could account for the differences in the approachs that are taken to fulfill this scenario between Silverlight and WPF.

I hope you find this helpful.

Guido Leandro Maliandi
http://blogs.southworks.net/gmaliandi

May 23, 2011 at 3:22 AM

Dear GuidoMaliandi,

Thanks a lot for you explanations!

And i've got another question now, which is not relevant to this one, so i will put it as a new thread. Would you please give it a check? Thanks a lot!

 

Sincerely rambo/Yuan Bo