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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:45:11+00:00 2026-05-27T07:45:11+00:00

i have a style with datatemplate in xaml page as shown below . <

  • 0

i have a style with datatemplate in xaml page as shown below .

<

    Style x:Name="mytemplate" x:Key="mytemplate"  xmlns:dataprimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"
                                TargetType="dataprimitives:DataGridColumnHeader">
                <Setter Property="ContentTemplate" >
                    <Setter.Value>
                        <DataTemplate>
                            <StackPanel Background="Aqua" Height="{Binding this.DataGridColumnHeader.Height}" Width="{Binding this.DataGridColumnHeaderWidth}" >
       <TextBlock Text="{Binding}"   HorizontalAlignment="Center" FontWeight="Black" ></TextBlock>
                                 <TextBox x:Name="{Binding}" Padding="0,-1,0,0"  HorizontalAlignment="Stretch" Width="100" Height="20" KeyDown="txtfilterBox_KeyDown" LostFocus="txtfilterBox_LostFocus" />
                            </StackPanel>
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

this style would be applied to the silverlight datgrid column header style.
now i want the stackpanel inside the template to be same as the height and width of the
silverlight datgrid column header ? so how can that be done?

else how to stretch the content template to fill the whole space of the datagrid column header

  • 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-05-27T07:45:11+00:00Added an answer on May 27, 2026 at 7:45 am

    Have you tried setting the StackPanel’s horizontal and vertical alignment properties to stretch? You shouldn’t need to bind to the Width and Height properties of the parent container at all.

    If setting the StackPanel to stretch that doesn’t work, simply wrap the stack panel in a Border and you will be golden. See the code below:

    <Style x:Name="mytemplate" x:Key="mytemplate"  xmlns:dataprimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"
                                        TargetType="dataprimitives:DataGridColumnHeader">
                        <Setter Property="ContentTemplate" >
                            <Setter.Value>
                                <DataTemplate>
                        <Border Background="Aqua" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                                        <StackPanel>
                              <TextBlock Text="{Binding}"   HorizontalAlignment="Center" FontWeight="Black" ></TextBlock>
                                          <TextBox x:Name="{Binding}" Padding="0,-1,0,0"  HorizontalAlignment="Stretch" Width="100" Height="20" KeyDown="txtfilterBox_KeyDown" LostFocus="txtfilterBox_LostFocus" />
                                        </StackPanel>
                        </Border>
                                </DataTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list box like below. <ListBox x:Name=CouponListBox ItemsSource={Binding Item} SelectionChanged=CouponListBox_SelectionChanged> <ListBox.ItemTemplate> <DataTemplate>
I have style sheet with a class name changebackgroundcolor i want make change in
I have the following XAML (simple list box with custom DataTemplate). I'm trying to
I have XAML: <TextBlock Text=Param 1 name Margin=6,6,0,0></TextBlock> <TextBox Text={Binding Param1Value, UpdateSourceTrigger=PropertyChanged} Margin=6,6,0,0></TextBox> <TextBlock
Right, what I have is: <Window x:Class=WpfGettingThingsDone.View.MainWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml AllowsTransparency=True Background=Transparent WindowStyle=None Title={Binding Title}
Let's say I have the follwoing listview in xaml: <ListView Name=myListView DataContext={Binding MyProperty} ItemsSource={Binding}
I have a DataTemplate in app.xaml that binds a view to a viewmodel. <Application.Resources>
i have ListBox on my xaml page called MainListBox. i can get index that
I have the following ItemsControl page... <Page x:Class=Kiosk.View.ItemListView xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006 xmlns:d=http://schemas.microsoft.com/expression/blend/2008 xmlns:Converter=clr-namespace:Kiosk.Converter mc:Ignorable=d
i have the following datatemplate in xaml and here i have textbox in datatemplate

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.