Ticket Q306393
Visible to All Users

How to use DXControl ItemHeaderTemplate

created 14 years ago

I have the following XAML
        <dx:DXTabControl ItemsSource="{Binding List}">
            <dx:DXTabControl.ItemHeaderTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Label}"/>
                </DataTemplate>
            </dx:DXTabControl.ItemHeaderTemplate>
        </dx:DXTabControl>
The List property in the DXTabControl 's DataContext contains a list of UserControls.
Each usercontrol, has in its DataContext a property "Label".
I would expect to see the Label value in my 2 tabs header but it doesn't work.
Could you help ?

Comments (3)
DevExpress Support Team 14 years ago

    Hi Sylvain,
    Thank you for providing the sample code.
    On my side, bindings inside the DXTabControl's ItemHeaderTemplate works as expected. So, I am afraid I do not quite understand how to reproduce the problem. I am attaching a small sample I used for testing purposes. Can you please let us know how we should modify it in order to see the issue in action, so that we can continue working on it?
    Thanks,
    Vito

      In your sample, if TabItemInfo inherits from UserControl then it doesn't work anymore !
      Because, I'm using DXTabControl as a Prism region, I'm putting some UserControls in the collection binded to DXTabControl.ItemsSource.

      DevExpress Support Team 14 years ago

        Hi Sylvain,
        Thank you for your response, and for providing the additional information.
        I now see the problem. This seems to be a well-known issue with binding to the UserControl properties. I suggest that you refer to the following thread, where this issue is discussed, to find more information on this subject:
        Problem with binding TabControl to collection of UserControls
        The only solution we can suggest is to use a workaround, suggested in this thread: use the ItemContainerStyle to set up header bindings. I am attaching a modified project, illustrating this approach in action. Hopefully, you will find it helpful.
        Thanks,
        Vito

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.