【问题标题】:Button template is masking the clickable area of a button按钮模板掩盖了按钮的可点击区域
【发布时间】:2015-11-22 23:38:52
【问题描述】:

我有以下 UWP XAML:

<Button Content="Scan" 
    Command="{Binding CommandScan}" ToolTipService.ToolTip="Scan"
    Style="{StaticResource ButtonIconStyle}">
    <Button.Template>
        <ControlTemplate TargetType="Button">
            <resources:ScanIcon />
        </ControlTemplate>
    </Button.Template>
</Button>

ScanIcon 是一个包含矢量图像的用户控件。似乎正在发生的事情是图标掩盖了可点击的按钮区域 - 也就是说,我只能点击图标的绘制区域,按钮的背景(虽然仍在按钮的边框内)不可点击。

所以,我的问题是:是什么导致了这种行为,我该如何覆盖它?

【问题讨论】:

    标签: xaml windows-10 uwp vector-graphics


    【解决方案1】:

    您可以尝试不理会Button ControlTemplate 并将您的图像插入BackgroundButton。我的意思是——当你想要超越风格时,你不必开枪。如果您需要Button 与图像的形状完全相同,您可以尝试DrawingBrush,如下所述:Painting with Images, Drawings, and Visuals

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-15
      • 1970-01-01
      • 2013-04-02
      • 1970-01-01
      • 2014-11-15
      • 2020-03-24
      • 1970-01-01
      相关资源
      最近更新 更多