WPF: Disable ListBox, but enable scrolling

前端 未结 12 2104
佛祖请我去吃肉
佛祖请我去吃肉 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:15

    Another option worth considering is disabling the ListBoxItems. This can be done by setting the ItemContainerStyle as shown in the following snippet.

    
        
            
        
    
    

    If you don't want the text to be grey you can specify the disabled color by adding a brush to the style's resources with the following key: {x:Static SystemColors.GrayTextBrushKey}. The other solution would be to override the ListBoxItem control template.

    This question is pretty much the same as this one: There ain't ListBox.SelectionMode=“None”, is there another way to disable selection in a listbox? and my answer is the same.

提交回复
热议问题