WPF - Bind UserControl visibility to a property

前端 未结 2 2052
暖寄归人
暖寄归人 2021-01-04 02:41

I have a ListView bound to ObservableCollection. Data are loaded from the internet and then added to collection. The download takes few seconds and I want to indicate user t

2条回答
  •  失恋的感觉
    2021-01-04 03:26

    I would recommend using a IValueConverter to accept your boolean, and return a member of Visibility enumeration.

    Here is a good example of one: http://jeffhandley.com/archive/2008/10/27/binding-converters---visibilityconverter.aspx

    The XAML would look like this:

    First you define a resource for the converter (put this in a resource dictionary):

    
    

    And then change your template like this:

    
        
            
        
    
    

提交回复
热议问题