wpf - 小按钮wpf内的图标

标签 wpf xaml

我正在尝试在小 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>

这是它的样子:

enter image description here

左边是按钮,右边是图标

最佳答案

试试这个:

<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>

运行时应该是这样的:

enter image description here

关于wpf - 小按钮wpf内的图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50904056/

相关文章:

c# - WPF自定义控件依赖属性中未知对象的双向绑定(bind)问题

c# - 在 MVVM WPF 中将 DataTable 绑定(bind)到 DataGrid

c# - 绑定(bind) ComboBox ItemsSource 在 WPF 中不起作用

c# - Clr 命名空间映射到默认 xaml 命名空间

c# - 绑定(bind)到 WPF 中的扩展方法

c# - 如何为 TextBox 数组创建处理事件

WPF ObjectDataProvider 参数

c# - 如何将文本 block 动态添加到页面?

c# - 我应该以哪种方式定义资源字典以保持我的代码干净?

c# - 我可以在 Xamarin 项目的 XAML 中绘制圆形、椭圆或正方形吗?