Wpf 对于动态大小的工具提示,什么是正确的XAML?
我需要为标签创建一个Wpf 对于动态大小的工具提示,什么是正确的XAML?,wpf,xaml,Wpf,Xaml,我需要为标签创建一个工具提示,该标签的大小总是标签的两倍。我无法获得正确的工具提示大小 我的代码在这里;我包含了一个复杂的模板,但如果使用字符串值,问题是相同的: <Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
工具提示
,该标签的大小总是标签的两倍。我无法获得正确的工具提示大小
我的代码在这里;我包含了一个复杂的模板,但如果使用字符串值,问题是相同的:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="200" Height="200" Title="MainWindow">
<Window.Resources>
<ControlTemplate x:Key="Density">
<StackPanel>
<TextBlock Text="Take your RenderTransform out of the ToolTip tag itself...
<ToolTip Background="AliceBlue" Style="{StaticResource TTipStyle}" Template="{StaticResource Density}" />
将渲染转换从工具提示标记本身中移除
<Style x:Key="TTipStyle" TargetType="ToolTip">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="HasDropShadow" Value="True" />
<Setter Property="LayoutTransform">
<Setter.Value>
<ScaleTransform ScaleX="2" ScaleY="2" />
</Setter.Value>
</Setter>
</Style>
…然后在您的样式中删除RenderTransform和模板,并改为设置LayoutTransform: