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"

相关推荐
没有bug.的程序员16 分钟前
微服务中的数据一致性困局
java·jvm·微服务·架构·wpf·电商
Aevget1 小时前
DevExpress WPF中文教程:Data Grid - 如何绑定到有限制的自定义服务(二)?
wpf·devexpress·.net 10·data grid
没有bug.的程序员2 天前
SOA、微服务、分布式系统的区别与联系
java·jvm·微服务·架构·wpf·日志·gc
Macbethad2 天前
基于WPF的半导体设备配方管理程序技术方案
wpf
FuckPatience2 天前
WPF Geometry
wpf
武藤一雄3 天前
.NET 中常见计时器大全
microsoft·微软·c#·.net·wpf·.netcore
MarkHD3 天前
车辆TBOX科普 第70次 AUTOSAR Adaptive、容器化与云原生的融合革命
云原生·wpf
极客智造3 天前
WPF Behavior 实战:自定义 InvokeCommandAction 实现事件与命令解耦
wpf
L、2183 天前
Flutter 与 OpenHarmony 深度集成:构建分布式多端协同应用
分布式·flutter·wpf
布伦鸽3 天前
C# WPF -MaterialDesignTheme 找不到资源“xxx“问题记录
开发语言·c#·wpf