Conditional element in xaml depending on the binding content

后端 未结 3 1018
礼貌的吻别
礼貌的吻别 2020-12-29 07:09

Is it possible to display this TextBlock, only if the Address.Length > 0 ? I\'d like to do this directly into the xaml, I know I could put all my controls pr

3条回答
  •  渐次进展
    2020-12-29 07:44

    You can create a StringToVisibility converter.

    It will return Visibility.Visible if bound string is not null or empty and Visibility.Collapsed if it is.

    Use this converter while binding Address with Visibility property of your TextBlock.

    Example:

    
    

提交回复
热议问题