WPF中的工具提示字体

16

有人知道如何更改 UI 元素工具提示的字体吗?

3个回答

21

这会使得所有位置的工具提示变得非常大:

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
   <Page.Resources>
      <Style x:Key="{x:Type ToolTip}" TargetType="{x:Type ToolTip}">
         <Setter Property="FontSize" Value="24"/>
      </Style>
   </Page.Resources>
   <Grid>
      <Button Content="Hey" ToolTipService.ToolTip="Hey"/>
   </Grid>
</Page>
如果您想更改特定的工具提示,您可以定义与该工具提示更接近的样式,或者直接在工具提示中放置字体大小。
  <Button Content="Hey">
     <ToolTipService.ToolTip>
        <TextBlock FontSize="64" Text="Hey"/>
     </ToolTipService.ToolTip>
  </Button>

4
您可以通过将文本块添加为工具提示的子元素来实现此操作。
<TextBox>
    <TextBox.ToolTip>
        <ToolTip>
            <TextBlock FontFamily="Tahoma" FontSize="10" FontWeight="Bold" Text="My tooltip text"/>
        </ToolTip>
    <TextBox.ToolTip>
</TextBox>

1

1
我真的很想知道为什么是-1。 - ANeves
我没有下票,但可能需要指定它的TextBlock.FontFamily或TextBlock.FontSize或类似的属性。 - Chris Bordeman

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接