Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 对于动态大小的工具提示,什么是正确的XAML?_Wpf_Xaml - Fatal编程技术网

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: