我希望能够为其他控件的样式指定不同的工具提示样式
例如,我的工具提示风格为:
<Style x:Key="IconStyle" TargetType="Button">
<Setter Property="VerticalAlignment" Value="Center"></Setter>
<Setter Property="HorizontalAlignment" Value="Center"></Setter>
<Setter Property="Width" Value="20"></Setter>
<Setter Property="Height" Value="20"></Setter>
</Style>
我的图标图片的样式:
{{1}}
如何使这个按钮(带有style == IconStyle)具有我的工具提示风格?
答案 0 :(得分:1)
不要将工具提示放在iconStyle之外,而是将其放在图像样式资源中,并跳过这样的键:
php ./vendor/doctrine/doctrine-module/bin/doctrine-module orm:clear-cache:query
php ./vendor/doctrine/doctrine-module/bin/doctrine-module orm:clear-cache:metadata
php ./vendor/doctrine/doctrine-module/bin/doctrine-module orm:clear-cache:result
修改强>
或者您可以将其保留为全局或Windows资源,并在Iconstyle资源中引用它,如下所示:
<Style x:Key="IconStyle" TargetType="Image">
<Style.Resources>
<Style TargetType="{x:Type ToolTip}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToolTip}">
<Border Background="DarkSlateGray" BorderBrush="DarkGoldenrod" BorderThickness="1" CornerRadius="2">
<StackPanel Orientation="Horizontal">
<Image Width="32" Height="32" Source="Resources/info.png" />
<ContentPresenter Content="{TemplateBinding Content}"/>
</StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Style.Resources>
<Setter Property="VerticalAlignment" Value="Center"></Setter>
<Setter Property="HorizontalAlignment" Value="Center"></Setter>
<Setter Property="Width" Value="20"></Setter>
<Setter Property="Height" Value="20"></Setter>
</Style>
答案 1 :(得分:0)
为什么不能像这样设置图像样式:
<Image Width="32" Height="32" Source="Resources/info.png" Style="{StaticResource IconStyle}"/>