Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8217581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:30:22+00:00 2026-06-07T12:30:22+00:00

Have datgrid with dynamic columns number, like that: <DataGrid DataGridCell.Selected=DataGrid_GotFocus EnableColumnVirtualization=true EnableRowVirtualization=true Name=dataGrid1 DockPanel.Dock=Top

  • 0

Have datgrid with dynamic columns number, like that:

<DataGrid DataGridCell.Selected="DataGrid_GotFocus" EnableColumnVirtualization="true" EnableRowVirtualization="true" Name="dataGrid1" DockPanel.Dock="Top" AutoGenerateColumns="False" 
                   Height="120" Width="Auto" CanUserReorderColumns="False" CanUserResizeColumns="False" CanUserAddRows="false" CanUserResizeRows="False" CanUserSortColumns="False" CellEditEnding="dataGrid1_CellEditEnding">
                </DataGrid>

for (var i = datetime; i < datetime.AddDays(1); i += TimeSpan.FromHours(1))
        {
            var column = new DataGridTemplateColumn();
            column.Header = (i.Hour + 1).ToString();
            column.Width = 30;
            column.CellTemplate = (DataTemplate)XamlReader.Load(
                new MemoryStream(Encoding.Default.GetBytes(
                    @"<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'><TextBlock Text='{Binding ValuesExtended[" + i.Hour + @"].value_nullable, UpdateSourceTrigger=PropertyChanged}'/></DataTemplate>"
                )));
            column.CellEditingTemplate = (DataTemplate)XamlReader.Load(
                new MemoryStream(Encoding.Default.GetBytes(
                    @"<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'><TextBox Text='{Binding ValuesExtended[" + i.Hour + @"].value_nullable, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}'/></DataTemplate>"
                )));
            dataGrid1.Columns.Add(column);
        }

dataGrid1.ItemSource = data;

Now i want one special row with checkboxes instead of text, how can i do it?
Googled examples, found only checkbox columns.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:30:25+00:00Added an answer on June 7, 2026 at 12:30 pm

    Hi the Logic to do that is as

        <Window.Resources>
        <DataGridRow x:Key="dr">
            <DataGridRow.Template>
                <ControlTemplate>
                    <StackPanel Width="400" Orientation="Horizontal">
                    <CheckBox Width="100"/>
                    <CheckBox Width="100"/>
                    <CheckBox Width="100"/>
                    <CheckBox Width="100"/>
                    </StackPanel>
                </ControlTemplate>
            </DataGridRow.Template>
        </DataGridRow>
    </Window.Resources>
    <Grid >
        <DataGrid AutoGenerateColumns="False" Width="400" CanUserAddRows="True" ItemsSource="{Binding PhoneNumbers}" LoadingRow="DataGrid_LoadingRow">
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding Name}" Header="Name" Width="100"></DataGridTextColumn>
                <DataGridTextColumn Binding="{Binding Name}" Header="Name" Width="100"></DataGridTextColumn>
                <DataGridTextColumn Binding="{Binding Name}" Header="Name" Width="100"></DataGridTextColumn>
                <DataGridTextColumn Binding="{Binding Name}" Header="Name" Width="100"></DataGridTextColumn>
            </DataGrid.Columns>
        </DataGrid>
    
    </Grid>
    
    private void DataGrid_LoadingRow(object sender, DataGridRowEventArgs e)
        {
            if (e.Row.Item.ToString().Equals("{NewItemPlaceholder}"))
            {
                e.Row.Item = this.FindResource("dr");
                e.Row.DetailsVisibility = Visibility.Visible;
            }
    
        }
    

    This is not Exact but the idea is kind of same. I hope this will help

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataGrid that is setup like this: <DataGrid AutoGenerateColumns=True GridLinesVisibility=Horizontal IsReadOnly=True ItemsSource={Binding
I have a DataGrid component that displays a few columns of data. It has
I have a DataGrid in WPF app with several columns, including a Name column.
I have a dynamic DataGrid in which one of the columns is a CheckBox.
I have to create a XamDataGrid that shows a dynamic amount of columns for
In ASP.NET 3.5 I have a datagrid that is bound to a somwehat dynamic
I have DataGrid with Dynamic Columns. The columns will contain ItemRendrer. I'm not familiar
I have a WPF 4.0 DataGrid that is bound to a DataTable using AutoGenerateColumns=True.
I have a dynamic Datagrid that I have created. I am creating each column
I have a DataGrid that has auto generated columns. In side of the AutoColumnsGenerated

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.