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 8596403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:40:19+00:00 2026-06-12T00:40:19+00:00

Hi have a very simple WPF DataGrid layout as follows: <wpftk:DataGrid Grid.Row=1 x:Name=myOrdersGrid ColumnHeaderStyle={DynamicResource

  • 0

Hi have a very simple WPF DataGrid layout as follows:

<wpftk:DataGrid Grid.Row="1"
        x:Name="myOrdersGrid"
        ColumnHeaderStyle="{DynamicResource FilterColumnHeaderStyle}"
        CanUserResizeColumns="True"
        VerticalAlignment="Stretch"
        HorizontalAlignment="Stretch">

  <wpftk:DataGrid.Resources>
    <Style x:Key="FilterColumnHeaderStyle" TargetType="{x:Type Primitives:DataGridColumnHeader}">
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type Primitives:DataGridColumnHeader}">
            <WrapPanel Width="50" Orientation="Vertical">
              <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Stretch"  />
              <TextBox Text="Hello" FontSize="10" Background="OldLace" HorizontalAlignment="Center" />
            </WrapPanel >
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>
  </wpftk:DataGrid.Resources>

  <wpftk:DataGrid.Columns>
    <wpftk:DataGridTextColumn SortMemberPath="Name" Binding="{Binding Name}" IsReadOnly="True"/>
    <wpftk:DataGridTextColumn SortMemberPath="Name" Binding="{Binding Price}" IsReadOnly="True"/>
  </wpftk:DataGrid.Columns>
</wpftk:DataGrid>

The intention is to drop a textbox into each header, in order to act as a filter.

However, when this renders, I get an extra textbox floating halfway across the datagrid, as follows:

DataGrid with extra column

Anyone know why? I’ve played around with all sorts of settings etc, but can’t figure out why this is happening (let alone how to fix it….). The extra textbox doesn’t seem to be enabled/clickable so it looks like it’s some sort of disabled/glasspaned scenario.

  • 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-12T00:40:21+00:00Added an answer on June 12, 2026 at 12:40 am

    Okay, so I found the issue. The extra control appears to be being put in the ‘filler’ column that the datagrid automatically inserts between the last defined column and the RHS of the datagrid.

    A better way to do this is to use a ContentTemplate for the header control as follows:

    <Style x:Key="FilterColumnHeaderStyle" TargetType="{x:Type Primitives:DataGridColumnHeader}">
          <Setter Property="ContentTemplate">
            <Setter.Value>
              <DataTemplate>
                <WrapPanel Orientation="Vertical">
                  <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Stretch"  />
                  <TextBox Text="{grid:GridFilter UpdateSourceTrigger=PropertyChanged}"
                      Visibility="{Binding ElementName=FilterCheckbox, Path=IsChecked, Converter={StaticResource b2v}}"
                      FontSize="10" Width="50" Background="OldLace" HorizontalAlignment="Center" />
                </WrapPanel >
              </DataTemplate>
            </Setter.Value>
          </Setter>
        </Style>
    

    This means the customised headers retain the correct style from the grid and have the thumbs etc included without having to explicitly declare them in the XAML.

    Still interested to know whether the extra column in the datagrid is a bug though (for templating purposes) – I read an article which indicated that it’s fixed in .Net 4.

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

Sidebar

Related Questions

Say I have a very simple WPF grid (6 rows x 6 columns) defined
I have a VERY simple 3D space defined in WPF, which defines a 3D
I'm a newbie with WPF and c# and have a (probably very simple) problem.
Here's my hypothetical example. I have a very simple WPF window with a one
I have a very simple WPF user control that is mixed in with a
I have encountered something very strange, simple WPF application <Window x:Class=ListBoxSelection.MainWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title=MainWindow
I'm working on a WPF project and have implemented a very simple way to
I have created a very simple wpf app with mvvm light. I have rows
I have a simple WPF application where I display one very large image (9000x2875)
I have a very simple WPF application in which I am using data binding

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.