New to Telerik UI for WinUI? Download free 30-day trial

Boolean Column

The DataGridBooleanColumn is used to represent boolean values. It uses а CheckBox control to edit its values in EditMode.

Example

The following example shows how to generate DataGridBooleanColumn manually. First we need to create our business object.

Example 1: Create Data model

public class Data 
{ 
    public string Product { get; set; } 
    public bool Stock { get; set; } 
} 
The next step is to create sample data.

Example 2: Create Sample Data

public MainPage() 
{ 
    this.InitializeComponent();  
    this.DataContext = new List<Data>() 
    { 
        new Data { Product = "Milk", Stock = true }, 
        new Data { Product = "Cheese", Stock = false }, 
        new Data { Product = "Bread", Stock = false }, 
        new Data { Product = "Chocolate", Stock = true }  
    }; 
}    
We have also used the PropertyName property to associate each column with the relevant property from our model.

Example 3: Defining in XAML

<telerikGrid:RadDataGrid ItemsSource="{Binding}" AutoGenerateColumns="False"> 
    <telerikGrid:RadDataGrid.Columns> 
        <telerikGrid:DataGridTextColumn PropertyName="Product" Header="Product"/> 
        <telerikGrid:DataGridBooleanColumn PropertyName="Stock" Header="Stock"/> 
    </telerikGrid:RadDataGrid.Columns> 
</telerikGrid:RadDataGrid> 

Figure 1: Boolean Column

Boolean Column

In this article
Not finding the help you need?