[C#][UWP] How to display text instead of checkboxes in DataGridBooleanColumn

2 posts, 0 answers
  1. Milan
    Milan avatar
    12 posts
    Member since:
    Mar 2016

    Posted 10 Apr 2017 Link to this post

    Hi Team,

    I have a RadDataGrid, wherein, I have multiple autogenerated columns and I want to display "yes/no" text in DataGridBooleanColumn but I could not find any way to do so.

    Could you please help me to achieve this scenario?


  2. Lance | Manager - Technical Support
    Lance | Manager - Technical Support avatar
    1112 posts

    Posted 10 Apr 2017 Link to this post

    Hello Milan,

    For this, you need to use a TemplateColumn with a TextBlock.

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
                <local:BoolToYesNoConverter x:Key="BoolToYesNoConverter"/>
                    <grid:DataGridTemplateColumn Header="Country">
                                <TextBlock Text="{Binding MyBoolProperty, Converter={StaticResource BoolToYesNoConverter}}" />

    Note that if your bound object is a bool, then you'll also need to use a converter to return the string values of "Yes" and "No"

    For example:

    class BoolToYesNoConverter : IValueConverter
            public object Convert(object value, Type targetType, object parameter, string language)
                return (bool) value ? "Yes" : "No";
            public object ConvertBack(object value, Type targetType, object parameter, string language)
                throw new NotImplementedException();

    You can find more information about column types and properties here.

    Lance | Tech Support Engineer, Sr.
    Telerik by Progress
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top