WPF: Display a bool value as “Yes” / “No”

后端 未结 7 1887
盖世英雄少女心
盖世英雄少女心 2020-11-30 00:21

I have a bool value that I need to display as \"Yes\" or \"No\" in a TextBlock. I am trying to do this with a StringFormat, but my StringFormat is ignored and the TextBlock

相关标签:
7条回答
  • 2020-11-30 01:14

    There is also another really great option. Check this one : Alex141 CalcBinding.

    In my DataGrid, I only have :

    <DataGridTextColumn Header="Mobile?" Binding="{conv:Binding (IsMobile?\'Yes\':\'No\')}" />
    

    To use it, you only have to add the CalcBinding via GitHub, than in the UserControl/Windows declaration, you add

    <Windows XXXXX xmlns:conv="clr-namespace:CalcBinding;assembly=CalcBinding"/>
    
    0 讨论(0)
提交回复
热议问题