Customizing the toggle state of a toggle button in wpf

前端 未结 4 656
我在风中等你
我在风中等你 2020-12-30 11:48

I wanna customize the toggle state of the toggle button in wpf. I want to set a image to the toggle button when it is on and set another image when it is off. TO do so, i th

4条回答
  •  囚心锁ツ
    2020-12-30 12:15

    Here is a ToggleButton with 3 images and a popup:

    1. An image for when IsChecked = false.
    2. An image for when IsChecked = true.
    3. An image for when IsMouseOver = true.

    The images are stored in resources as BitmapImage in order to avoid changing Visuals on trigers.

    The image files have to be added to resources and then, the files added to the "Resoruces" folder in the project have to be marked as BuildAction = Resource.

    It also applies an opacity to the Image control when the ToggleButton IsEnabled = false;

    Code:

        
            
                
                
                
            
    
            
                
            
                
    
        
            
                
                
        
    

提交回复
热议问题