【WPF】Button按钮添加背景图片

只是想做一个很简单的图片按钮而已,不需要那么复杂。

<Button x:Name="btn" Width="145" Height="30" HorizontalAlignment="Center" Margin="5"  VerticalAlignment="Top" Command="{Binding BtnCommand}"> 
    <Button.Background>
        <ImageBrush ImageSource="图片路径" Stretch="Fill"/> <!--如"/项目名;component/Presentation/Resources/Images/1.png"-->
    </Button.Background>
</Button>

 

坑点:

  • 如果Visual Studio报错说在Button下找不到Background属性,那是因为图片路径填写错了!
posted @ 2017-01-10 09:14  霍莉雪特  阅读(3658)  评论(0编辑  收藏  举报