WPF设置Button背景

一个方法是把Button的Content设置为<Image/>
另一个方法是设置Button的Style属性。
< Window  x:Class ="WpfApp.Window1"
        xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml"
        Title
="http://dotnet.5d6d.com"  Height ="384"  Width ="614" >
    
< Grid >
        
< Button  Height ="140"  HorizontalAlignment ="Left"  Margin ="10,10,0,0"  VerticalAlignment ="Top"  Width ="140" >
            
< Image  Source ="img/bg1.jpg" ></ Image >
        
</ Button >
        
< Button  Style =" {DynamicResource btnTemp} " > hi </ Button >
    
</ Grid >
    
< Window.Resources >
        
< Style  x:Key ="btnTemp"  TargetType =" {x:Type Button} " >
            
< Setter  Property ="Control.Background"  Value ="blue" ></ Setter >
            
< Setter  Property ="Control.Margin"  Value ="160,10,0,0" ></ Setter >
            
< Setter  Property ="Control.Width"  Value ="140" ></ Setter >
            
< Setter  Property ="Control.Height"  Value ="140" ></ Setter >
            
< Setter  Property ="Control.HorizontalAlignment"  Value ="Left" ></ Setter >
            
< Setter  Property ="Control.VerticalAlignment"  Value ="Top" ></ Setter >
        
</ Style >
    
</ Window.Resources >
</ Window >
SEO http://greatverve.cnblogs.com/archive/2011/06/03/button-background.html

转载于:https://www.cnblogs.com/greatverve/archive/2011/06/03/button-background.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值