Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7511087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:26:41+00:00 2026-05-29T23:26:41+00:00

Given the following XAML: <TabControl DataContext={StaticResource mainVM} ItemsSource={Binding MovableVM.Docked, UpdateSourceTrigger=PropertyChanged}> <TabControl.ItemTemplate> <DataTemplate> <TextBlock> <TextBlock

  • 0

Given the following XAML:

<TabControl DataContext="{StaticResource mainVM}" ItemsSource="{Binding MovableVM.Docked, UpdateSourceTrigger=PropertyChanged}">
        <TabControl.ItemTemplate>
            <DataTemplate>
                <TextBlock>
                    <TextBlock Text="{Binding ContentTitle}"/>
                </TextBlock>
            </DataTemplate>
        </TabControl.ItemTemplate>
        <TabControl.ContentTemplate>
            <DataTemplate>
                <ContentPresenter Content="{Binding}"/>
            </DataTemplate>
        </TabControl.ContentTemplate>
</TabControl>

I expected both DataTemplates to have the same DataContext with the expected result that the actual items from the ItemsSource (a UserControl implementing the interface IMovable, see below) being displayed within separate tabs and the header of each tab to display the contents of the property ContentTitle of the same item.

The IMovable object is displayed as expected, but the binding to the ContentTitle is not working for the header. If I change the the binding in the ContentTemplate, like so…

<TabControl.ContentTemplate>
    <DataTemplate>
        <ContentPresenter Content="{Binding ContentTitle}"/>
    </DataTemplate>
</TabControl.ContentTemplate>

…I do get the contents of the ContentTitle property instead of the item, so the property itself is bindable.

Here’s the IMovable interface:

public interface IMovable : INotifyPropertyChanged
{
    string ContentTitle { get; }
}

So my question is: Is there a different DataContext in the ItemTemplate (if so, what is it?) or is there another reason the binding in the ItemTemplate isn’t working as I expect?

Update:
I’ve created a small example application that shows the problem clearly. If things had worked as expected, there would be a text below each Ellipse in each tab, and the DataContext of the Ellipse would not be null. It can be downloaded here: Example App

Update
It works if using a custom class Foo::DependencyObject and making the ContentTitle property into a DependencyProperty. Though changing the property in the original class does not work. I need to sleep on this….

Update
I’ve narrowed down the problem, but the findings are not at all what I expected. WpfApplication2 shows that adding items to the ItemsSource that are either POCO or derived from DependedcyObject works as expected. However, items derived from UserControl do not give the expected result. I would appreciate if someone you have a look at it. Simply run the application and you’ll see that one Tab header is missing the text.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T23:26:43+00:00Added an answer on May 29, 2026 at 11:26 pm

    The problem here is that the DataTemplate will see an object witch inherits from Visual. This type of object do not need any visual representation through a DataTemplate. There is a discussion about it on this post.

    DataTemplate DataType property doesn’t work on types inherited from Control

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following XAML fragment: <ComboBox ItemsSource={Binding ListOfItems} SelectedItem={Binding CurrentItem, Mode=TwoWay}/> It would seem
Given the following XAML... <ComboBox x:Name=advisoriesComboBox DisplayMemberPath=Name ItemsSource={Binding Path=Advisories} SelectedItem={Binding Path=SelectedAdvisory} /> <Button Command={Binding
I have the following xaml: <ItemsControl> <ItemsControl.ItemTemplate> <DataTemplate> <Button Content={Binding Name}></Button> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl>
Given the following XAML my goal is to keep the columns AAA, BBB, CCC
Given the following XAML markup, I would expect the text in the Hyperlink to
Given the following code: <Window x:Class=WpfApplication76.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:col=clr-namespace:System.Collections;assembly=mscorlib Title=Window1 Height=300 Width=300> <Window.Resources> <CollectionViewSource
given the following XAML code: <Canvas Name=MainView> <Canvas Name=TriangleElement Width=50 Height=50 Canvas.Left=110 Canvas.Top=100> <Canvas.RenderTransform>
Given the following xaml code, I would like to create this xaml code the
Given the following XAML code that with a ListControl like behavior: <StackPanel> <ItemsControl Name=_listbox
Given the following bit of XAML <Border Name=Brder Visibility=Visible Width=10 Height=10 Background=Red></Border> <Button Content=Hide></Button>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.