How does WPF handle binding to the property of a null object?

前端 未结 1 1518
故里飘歌
故里飘歌 2021-02-05 07:32

I have a listBox using an itemTemplate that contains the following line:

 
         


        
1条回答
  •  佛祖请我去吃肉
    2021-02-05 08:10

    In BindingBase have two properties: TargetNullValue and FallbackValue.

    TargetNullValue returns your value when the value of the source is null.

    FallbackValue returns your value when the binding is unable to return a value.

    Example of using:

    
    
    
        
        
    
        
        pack://application:,,,/NotFound.png
    
        
        pack://application:,,,/NullImage.png
    
    
    
        
    
        
    
    

    See this links, for more information:

    BindingBase.TargetNullValue Property

    BindingBase.FallbackValue Property

    0 讨论(0)
提交回复
热议问题