Change Button Image On Hover or Click

后端 未结 6 641
没有蜡笔的小新
没有蜡笔的小新 2020-12-10 19:58

How do I change the background image of a Button on Hover and on Click? The Visual Studio\'s UI does not seem to provide any easy way of doing it. Currently the default beha

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-10 21:02

    You're pretty much there. You can always apply a semi-transparent colour on top of your picture below your text/content but since you asked for changing the entire image, here's what you can do:

    In Visual Studio 2012, if you already have a button mostly styled/configured to what you want, right click it, Edit Template -> Edit a Copy. Choose where you want to put the new style/template. It's like picking where to put the CSS. Could be in a global file (App.xaml or StandardStyle.xaml) or in the header (page resources) or inline (control resources).

    The below XAML might be over-simplified and not work but it's the idea of it:

    
        
            
                
                    
                    
                        
                            
                                
                            
                        
                    
                    
                        
                            
                                
                            
                        
                    
                    [...]
                
                
                    [...]
                
            
            
                
                    
                    
                    
                    
                
            
            [...]
        
    
    

    Now you can place your 3 images in the 3 tags and since the ContentPresenter is on top, when you use the template with

提交回复
热议问题