Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
180
Customizing Tab Headers with XamTabControl
posted

I would like to (a) wrap the text in a tab header i.e. "this is a long tab header" would be displayed as something like:

this is a long

tab header

(b) "escape" an ampersand in a tab header i.e. "this & this is causing me a problem"

(c) change the shape of a tab header to something like a rectangle on it's side with a triangle at the RHS whose point faces rightwards (this is to replicate a wire frame that your colleague Tobias produced for us a few weeks back). I have seen plenty of samples that effect rounded corners for tab headers but we would like to go beyond this.

Thanks

John French

 

 

 

  • 54937
    Suggested Answer
    Offline posted

    JohnFrench said:
    I would like to (a) wrap the text in a tab header

    If you want wrapping you would probably need to set a MaxWidth on the TabItem and provide a DataTemplate that would use a TextBlock with wrapping enabled. e.g.

    <TabItem Header="This is a long block of text to show wrapping" 
             MaxWidth="50">
        <TabItem.HeaderTemplate>
            <DataTemplate>
                <TextBlock TextWrapping="Wrap" Text="{Binding}" />
            </DataTemplate>
        </TabItem.HeaderTemplate>

     

    JohnFrench said:
    (b) "escape" an ampersand in a tab header

     In xaml you would have to use the standard xml escapements for special characters. & would be &amp; - e.g. "this &amp; this is causing me a problem"

    JohnFrench said:
    (c) change the shape of a tab header to something like a rectangle

    You would need to create a custom ControlTemplate for the TabItem(Ex). I do not have any examples of any such templates but you can use the default templates we ship with the product - located in the DefaultStyles directory - as a starting point.