【问题标题】:icon inside small button wpfwpf小按钮内的图标
【发布时间】:2020-01-27 16:46:18
【问题描述】:

我正在尝试在小 Button 内添加图标,但它没有按需要输入,

这里是我的 xaml:

<Button x:Name="eye_button"  BorderBrush="{x:Null}"   Margin="234,0,0,0"  Height="15" Width="15">                                     
        <materialDesign:PackIcon Kind="Eye"   Foreground="Black" />
  </Button>

它的外观如下:

左边是按钮,右边是图标

【问题讨论】:

  • 没有足够的信息,如果可能的话,你能粘贴整个 XAML 吗?
  • 尝试为图标添加高度和宽度。

标签: wpf xaml


【解决方案1】:

试试这个:

<Button x:Name="eye_button" BorderBrush="{x:Null}"  Margin="234,0,0,0" HorizontalAlignment="Left">
    <materialDesign:PackIcon Kind="Eye" Foreground="Black" Width="15" Height="15" />
</Button>

它在运行时应该是这样的:

【讨论】:

    【解决方案2】:
     <Button
        Width="15"
        Height="15"
        Padding="0"
        HorizontalAlignment="Center"
        HorizontalContentAlignment="Center"
        VerticalContentAlignment="Center"
        Background="Transparent"
        BorderThickness="0"
        Foreground="Red">
    
        <materialDesign:PackIcon
            Width="15"
            Height="15"
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            Foreground="Black"
            Kind="ArrowBack" />
    </Button>
    

    确保将填充设置为 0

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-16
      • 2019-06-02
      相关资源
      最近更新 更多