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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T04:59:07+00:00 2026-05-11T04:59:07+00:00

I have a WPF ListBox with a defined DataTemplate. In that template, I have

  • 0

I have a WPF ListBox with a defined DataTemplate. In that template, I have a grid, where the first column width should take up all remaining room in the grid.

This seems to work outside the ListBox, but not inside. Why is that, and how can I get it to behave the same?

Here is my code. See line 36, and line 70

 <UserControl x:Class='Russound.Windows.UI.UserControls.MAX.Reports.UniversalReportsWpf'         xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'         xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'         Height='250' Width='900'  >         <Grid>             <Grid.RowDefinitions>                 <RowDefinition Height='Auto'/>                            <RowDefinition Height='*'/>             </Grid.RowDefinitions>                 <Grid>                     <Grid.RowDefinitions>                         <RowDefinition Height='Auto'/>                         <RowDefinition Height='Auto'/>                     </Grid.RowDefinitions>                                <TextBlock Grid.Row='0' Height='35' Padding='0,3,5,0' Text='Standard Reports' HorizontalAlignment='Right' FontWeight='Bold' FontSize='20' Foreground='DarkBlue'/>                 <Border Grid.Row='1'>                     <Grid>                         <Grid.Resources>                             <Style TargetType='{x:Type TextBlock}'>                                 <Setter Property='HorizontalAlignment' Value='Left'/>                                 <Setter Property='VerticalAlignment' Value='Top'/>                                 <Setter Property='Height' Value='20'/>                                 <Setter Property='Padding' Value='0,3,5,0'/>                                 <Setter Property='Cursor' Value='Hand'/>                                 <Setter Property='Foreground' Value='WhiteSmoke' />                             </Style>                         </Grid.Resources>                         <Grid.Background>                             <LinearGradientBrush EndPoint='0.5,1' StartPoint='0.5,0'>                                 <GradientStop Color='#FF808080' Offset='0'/>                                 <GradientStop Color='#FF000000' Offset='1'/>                             </LinearGradientBrush>                         </Grid.Background>                         <Grid.ColumnDefinitions>                             <ColumnDefinition Width='300*' />                             <ColumnDefinition Width='150' />                             <ColumnDefinition Width='100' />                             <ColumnDefinition Width='50' />                         </Grid.ColumnDefinitions>                         <TextBlock Grid.Column='0' Text='Report Name' FontWeight='Bold'/>                         <TextBlock Grid.Column='1' Text='Last Run Date' FontWeight='Bold'/>                         <TextBlock Grid.Column='2' Text='Last Ran By' FontWeight='Bold'/>                         <TextBlock Grid.Column='3' Text='Secure' FontWeight='Bold'/>                     </Grid>                 </Border>             </Grid>             <ListBox Grid.Row='1'  ItemsSource='{Binding}'                       ItemTemplate='{DynamicResource reportLayout}'                       VirtualizingStackPanel.VirtualizationMode='Recycling'                      MouseDoubleClick='DisplaySelectedReport' Grid.RowSpan='2'>                 <ListBox.SelectedItem>                     <MouseBinding MouseAction='LeftDoubleClick'                   Command='ApplicationCommands.Open' />                 </ListBox.SelectedItem>                 <ListBox.Resources>                     <DataTemplate x:Key='reportLayout' DataType='AdHockReport'>                         <Grid>                             <Grid.Resources>                                 <Style TargetType='{x:Type TextBlock}'>                                     <Setter Property='HorizontalAlignment' Value='Left'/>                                     <Setter Property='VerticalAlignment' Value='Top'/>                                     <Setter Property='Height' Value='25'/>                                     <Setter Property='Padding' Value='0,3,5,0'/>                                     <Setter Property='Cursor' Value='Hand'/>                                 </Style>                                                         </Grid.Resources>                                  <Grid.ColumnDefinitions>                                 <ColumnDefinition Width='*' />                                 <ColumnDefinition Width='150' />                                 <ColumnDefinition Width='100' />                                 <ColumnDefinition Width='50' />                             </Grid.ColumnDefinitions>                              <TextBlock Grid.Column='0' ToolTip='Report Name' Text='{Binding Path=DisplayName}' FontWeight='Bold'/>                             <TextBlock Grid.Column='1' ToolTip='Last Run Date' Text='{Binding Path=LastRunDate, StringFormat=MMM dd\, yyyy h:mm tt}' />                             <TextBlock Grid.Column='2' ToolTip='Last Run By' Text='{Binding Path=LastRunBy}' />                             <TextBlock Grid.Column='3' ToolTip='Secure' Text='{Binding Path=IsSecure}' />                         </Grid>                                         </DataTemplate>                 </ListBox.Resources>                 <ListBox.Background>                     <LinearGradientBrush EndPoint='0.5,1' StartPoint='0.5,0'>                         <GradientStop Color='#FFE5E5E5' Offset='0'/>                         <GradientStop Color='#FF888888' Offset='1'/>                     </LinearGradientBrush>                 </ListBox.Background>                        </ListBox>          </Grid>     </UserControl> 
  • 1 1 Answer
  • 3 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. 2026-05-11T04:59:08+00:00Added an answer on May 11, 2026 at 4:59 am

    This is because the ListBoxItem containing the grid is sizing to content. Therefore the ‘remaining space’ for the star-sized column to fill is only as much as the column needs.

    To fix this, use the ListBox.ItemContainerStyle to set ListBoxItem.HorizontalContentAlignment to Stretch.

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

Sidebar

Related Questions

I have a WPF Listbox defined in a DataTemplate that has its ItemsSource bound
I have a wpf listbox that implements a DataTemplate that contains a TextBlock. <local:BooleanToFontColorConverter
I have defined style for my WPF listbox but am adding a rectangle manually
I have a WPF listbox and have updated the list item data template to
I have a WPF ListBox that I would like to Enable multiple selection in
I have created styled a ListBox in WPF so that it is rendered as
I have a WPF Listbox filled with children that fire events. Now, I am
I have a WPF application with ListBox that display list of items. Each item
I have a WPF listbox control that is declaratively bound to a textbox. The
I have a WPF app that has a ListBox . The drag mechanism is

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.