WPF 按钮内容显示图片或者图标,Path

XML 复制代码
<telerik:RadButton
    Name="btn_Reset"
    Grid.Column="1"
    Margin="2"
    FontSize="15">
    <Grid Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="1.3*" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Path
            Width="20"
            Height="20"
            Margin="1"
            Data="{StaticResource ResetFlowGeometry}"
            Fill="{telerik:VisualStudio2019Resource ResourceKey=IconBrush}"
            Stretch="Uniform" />
        <ContentPresenter Grid.Row="1" Content="复位" />
    </Grid>
</telerik:RadButton>

path可以换成image就可以显示图片了。

此种方法只是简单替换 Button 的内容为 Image,未涉及模板(ControlTemplate或DataTemplate)

在需要保持第三方原有样式时候非常好用

如果Path不显示,试一下: Stretch="Uniform"

相关推荐
czhc11400756632 小时前
7.23:Claude code:注册->封表
wpf
心平气和量大福大16 小时前
C#-WPF-控件-TextBox 数据绑定
开发语言·c#·wpf
listening7771 天前
HarmonyOS 6.1 全场景协同实战:从“单机”到“超级终端”的分布式重构
wpf
心平气和量大福大2 天前
C#-WPF-布局-Grid
c#·wpf·visual studio
心平气和量大福大3 天前
C#-WPF-Window主窗体
开发语言·c#·wpf
FuckPatience3 天前
Telerik UI for WPF 值不能为null。参数名:key
ui·wpf
lindexi3 天前
WPF 笔迹延迟优化从硬件到软件的全链路分析
wpf
weixin_727535624 天前
双Token认证体系深度拆解:Spring Security + JWT + Redis
redis·spring·wpf
liuxiaowei34 天前
Winform+WPF双框架实战:喷涂工艺SCADA上位机从0到1搭建(附采集监控源码+车间踩坑实录)
大数据·hadoop·wpf
贺国亚5 天前
模型训练-分布式与GPU调度
分布式·wpf