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
The following worked for me inside a datagridtextcolumn: I added another property to my class that returned a string depending on the value of MyBool. Note that in my case the datagrid was bound to a CollectionViewSource of MyClass objects.
C#:
public class MyClass
{
public bool MyBool {get; set;}
public string BoolString
{
get { return MyBool == true ? "Yes" : "No"; }
}
}
XAML: