WPF - Bind UserControl visibility to a property

前端 未结 2 2039
暖寄归人
暖寄归人 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:24

    Use .NET's built in Converter

    .NET 3 has a built in BooleanToVisibilityConverter.

    (Note: May not be available on all platforms, ex: mobile)

    First add it to your Resources

    
        
    
    

    Then use it on an element

    Inverting

    How do I invert BooleanToVisibilityConverter?

    If you want to invert the converter (ex: hide the element when your property is true), this answer has a custom implementation of IValueConverter that supports that via XAML

    
        
    
    

提交回复
热议问题