WPF: Disable ListBox, but enable scrolling

前端 未结 12 2315
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-05 05:33

Been banging my head against this all morning.

Basically, I have a listbox, and I want to keep people from changing the selection during a long running process, but

12条回答
  •  滥情空心
    2021-01-05 06:18

    Well, I found a sweet way to provide this feature. What I did is that in the DataTemplate of the listBox I binded the parent layout enable property with the boolean flag using Page as Source.

    Step 1 - Provide the x:Name attribute to the page. If the page you are using is extended with base page than make sure that the base page is not an abstract class and has an default constructor without any arguments.

    
    

    Step 2 - Use the Page as a source for the DataTemplate parent layout items IsEnabled property

    
        
            
                
            
        
    
    

提交回复
热议问题