Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit ContentTemplate for TabItem is not data binding properly
4 replies. Latest Post by UNSWITCH on November 6, 2009.
(0)
UNSWITCH
Member
0 points
3 Posts
11-04-2009 1:39 AM |
I am using the Oct 2009 Silverlight Toolkit with SL3 and I have a strange problem with how the ContentTemplate properly is working for a TabItem. If the Content property of a TabItem is set using the attribute syntax method as follows, the ContentTemplate is applied as expected as shown in the following code:
<!-- Shows a single TabItem whose content contains a grid with yellow background and the text "This is a test". -->
However, if the Content property of the TabItem is specified using element syntax, the ContentTemplate is applied, but the TabItems' Content is never data bound to the ContentPresenter inside of the ContentTemplate.
<!-- Shows a single TabItem whose content contains a grid with yellow background but does NOT display the expected text (Content is missing). -->
Can anyone shed some light on why this problem happens? I don't understand why in the second code snippet, the Content is not displayed when the ContentTemplate is applied?
Thanks in advance!
mchlsync
Star
14606 points
2,730 Posts
11-04-2009 8:46 AM |
I think it might be a bug. or at least, it's inconsistent with WPF.
11-04-2009 4:41 PM |
Some additional info...
This is causing me some major grief right now when trying to use the TabControl with Prism (Composite Application Library) and the TabControlRegionAdapter.
I was trying to modify the TabItem's ContentTemplate so I could wrap the view that gets added to the TabItem region with some additional Xaml that data binds to some properties on a View Model (sort of like how a HeaderTemplate can be used to data bind a TextBlock defined in the template to a property from the regions ViewModel).
However, when I created the ContentTemplate I could not get the ContentPresenter that is nested inside the DataTemplate to bind to the Content property and display the View. Thus, the view that gets added to the region is never displayed when a ContentTemplate is displayed. Only the XAML defined in the DataTemplate is displayed (which says to me the ContentTemplate is being applied, but databinding is not working).
I tried to simplify the problem by removing Prism from the picture and that's when I realized that what I am trying to do doesn't seem to work when using only the TabControl in SL3. It doesn't look like a Prism issue at the moment, but I'm relatively new to XAML so it's a bit of a struggle to trace this down.
Hope I explained that clearly...
Thanks!
Min-Hong...
Contributor
3619 points
412 Posts
11-06-2009 4:09 AM |
Hi Unswitch,
Thank you for report this issue. We are aware of this issue now. And the develop team is working on it.
So sorry for the inconvenience it brought you. If you need any help you can always come to us.
Best Regards
11-06-2009 10:59 AM |
Excellent, thanks for the quick response! I'll keep an eye out for the fix.