How to shrink size of the expander when collapsing the content and also how to make button interactive when used inside expander in avalonia?
06:27 30 Apr 2026

I am trying to fix issue of the custom expander style that I made in order to fix the height of the expander when user presses button to collapse the expander contents. Here is how I approached it,

In Main Window Application:



    
        
            
                
                
            

            
            
        
    
    
        

In app.axaml


        

            
            

Expander style

// Expander style section:


    
        
            
            
        
    

    
        
        
        

        
        

        
        

        
        
            M39.6339 31.8839C39.1457 32.372 38.3543 32.372 37.8661 31.8839L24 18.0178L10.1339 31.8839C9.64573 32.372 8.85427 32.372 8.36612 31.8839C7.87796 31.3957 7.87796 30.6043 8.36612 30.1161L23.1161 15.3661C23.6043 14.878 24.3957 14.878 24.8839 15.3661L39.6339 30.1161C40.122 30.6043 40.122 31.3957 39.6339 31.8839Z
        

        
            M8.36612 16.1161C7.87796 16.6043 7.87796 17.3957 8.36612 17.8839L23.1161 32.6339C23.6043 33.122 24.3957 33.122 24.8839 32.6339L39.6339 17.8839C40.122 17.3957 40.122 16.6043 39.6339 16.1161C39.1457 15.628 38.3543 15.628 37.8661 16.1161L24 29.9822L10.1339 16.1161C9.64573 15.628 8.85427 15.628 8.36612 16.1161Z
        

    

    
    
    

    

    
    
    

    

    

    

    

    

    


Button style

// Button (will be used inside expander):

  
    
      
        
            

When I am using the following the expander

Expander when content is collapsed

Expander when content is expanded and using Row definitions both Autos

if I modified the line in Expander from