0

I have a tabcontrol in which each tabITem is rendered a very big font symbol (see image below)

pic1 big font size for tab header

now the tooltip is set to a very big size according to the very big size of the aforementioned tabItem char.

enter image description here

What I'd like is to keep the tabItem symbol very big but being able to resize the tooltip font.

PLUS I can't understand why the tabheader tooltip is randomly set on all children. I want it on the tabheader itself and not floating everywhere!

enter image description here

--EDIT--- As requested here is a relevant part of my xaml. I only include tab2 which is shorter but there are several tabItems and all behave the same way.

 <!-- +++++++++++++ TAB2 ++++++++++++ -->
  <TabItem Name="tabItem2" HorizontalAlignment="Center" Height="80" IsSelected="false" FontSize="{StaticResource TAB_FONTSIZE}">
    <TabItem.Header>
      <StackPanel>
        <TextBlock Text="&#xF0F7;"/>  <-------------unicode symbol very big!
        <TextBlock Name="tbTab2" Visibility="Hidden" FontSize="{StaticResource BUTTON_FONTSIZE}" />
      </StackPanel>
    </TabItem.Header>
    <TabItem.Background>
      <ImageBrush/>
    </TabItem.Background>
  </TabItem>

while tooltip is set in code-behind

tabItem2.ToolTip = Langs.Word(Langs.eWords.Pallet);

and it gets the HUGE size of the aforementioned unicode char.

Thanx for any help

2
  • Can you include the relevant XAML for this? It looks like it's just a customized TabControl which would explain the random floating tooltip, and you can probably overwrite the .ToolTip to set it up however you want Commented Dec 1, 2015 at 16:48
  • 2
    I did a quick test with the XAML you posted, and neither problem occurs. It sounds like you have overridden the default TabControl.Template, and the problem lies in that code. Either that, or some kind of global style. Are you able to post that code? Alternatively, you could probably get a tool like Snoop and find out where the size is coming from using it. Commented Dec 1, 2015 at 18:22

1 Answer 1

1

The problem here is that you set both font size and tooltip directly on the TabItem, and those are then "inherited" by the item's header and content (the font size is also "inherited" by their tooltips). So in order to accomplish what you're asking you need to be more precise when setting those properties, i.e. set them on appropriate controls and not on the TabItem itself. In your case the following should work as expected.

You want to use the large font only for the unicode character, so set the FontSize property only on the control displaying that character:

<TextBlock Text="&#xF0F7;" FontSize="{StaticResource TAB_FONTSIZE}" />

You want the tooltip to be displayed only for the header, therefore you should set it on the header. You can do that either in XAML:

<TabItem.Header>
    <StackPanel ToolTip="My tooltip text">
    ...
    </StackPanel>
</TabItem.Header>

or in code-behind:

var stackPanel = (StackPanel)tabItem2.Header;
stackPanel.ToolTip = "My tooltip text";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.