I have a wpf (mvvm-light) based form, with Grid and a six buttons, three in a row in two columns. As buttons can be turned on/off in settings, I want to hide some of them, but I don't want to have empty spaces. How can I achieve this ?
            Asked
            
        
        
            Active
            
        
            Viewed 1,230 times
        
    -1
            
            
        - 
                    1Don't use a fixed Grid if you have dynamic content. Use a ListBox or a WrapPanel. – DrKoch Jan 26 '15 at 06:05
- 
                    Are you interested in dynamically adding buttons based on some logic? – Hari Prasad Jan 26 '15 at 06:22
- 
                    That can be one option. – Milan M. Jan 26 '15 at 07:33
1 Answers
3
            
            
        Use a WrapPanel and set the visibility for a hidden button to Visibility.Collapsed (not Visibility.Hidden which hides the control but the space for it is still reserved).  You could bind the visibility to a settings value for example.
See here: Difference between Visibility.Collapsed and Visibility.Hidden
 
    
    
        Community
        
- 1
- 1
 
    
    
        Tim Rutter
        
- 4,549
- 3
- 23
- 47
