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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:01:36+00:00 2026-05-24T11:01:36+00:00

I have a datagrid in which I display several objects with some columns. I

  • 0

I have a datagrid in which I display several objects with some columns. I added grouping to the datagrid and now it seems that it doens’t like the colulmns with width of ‘*’ – the columns are all collapsed to their minimum widths. However, when I refresh the grid (after adding an element or modifiying an existing one), I can see the columns refreshing alright.
The weird thing is that I call the same function twice and the first time it doesn’t work while the second it does.

Before :

http://www.microage-dil.ca/SO/GridBefore.png

After updating once

http://www.microage-dil.ca/SO/GridAfter.png
Here is the Refresh function :

Private Sub ListerDocuments()
    Dim lstCVDocuments As New ListCollectionView(_oLstDocuments)
    lstCVDocuments.GroupDescriptions.Add(New PropertyGroupDescription("TypeFichier"))

    GridDocuments.ItemsSource = lstCVDocuments
    GridDocuments.Items.Refresh()
End Sub

And now the datagrid :

<DataGrid x:Name="GridDocuments" Grid.Column="0" ItemsSource="{Binding}" Style="{StaticResource BaseGrid}"  IsTabStop="False">
    <DataGrid.GroupStyle>
        <GroupStyle>
            <GroupStyle.HeaderTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
                        <TextBlock Text="{Binding Path=Name}" />
                    </StackPanel>
                </DataTemplate>
            </GroupStyle.HeaderTemplate>
            <GroupStyle.ContainerStyle>
                <Style TargetType="{x:Type GroupItem}">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type GroupItem}">
                                <Expander>
                                    <Expander.Header>
                                        <StackPanel Orientation="Horizontal"  HorizontalAlignment="Stretch">
                                            <TextBlock Text="{Binding Path=Name}" FontWeight="Bold" />
                                        </StackPanel>
                                    </Expander.Header>
                                    <ItemsPresenter />
                                </Expander>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </GroupStyle.ContainerStyle>
        </GroupStyle>
    </DataGrid.GroupStyle>
    <DataGrid.Columns>                            
        <DataGridTextColumn Header="Nom" Width="2*"  MinWidth="150"
                            Binding="{Binding NomFichier}"                                               
                            IsReadOnly="True" />
        <DataGridTextColumn Header="Fichier" Width="3*"  MinWidth="150"
                            Binding="{Binding NomFichierOriginal}"                                               
                            IsReadOnly="True" />
        <DataGridTextColumn Header="Extension" Width="65"  MinWidth="50"
                            Binding="{Binding ExtensionFormate}"                                               
                            IsReadOnly="True" />
        <DataGridTextColumn Header="Date d'ajout" Width="80"  MinWidth="80"
                            Binding="{Binding  DateAjout, StringFormat=yyyy-MM-dd}"                                               
                            IsReadOnly="True" />
    </DataGrid.Columns>                        
</DataGrid>

I got the grouping part on the net and it seemed to work fine until I found tha tparticular bug. Note that I added the HorizontalAlignment =”Strech” because I though it might solve the problem but obviusly it did not.

EDIT : Forgot to mention, the first time I call the ListerDocument function, the variable is fully loaded with the documents and it is called in the constructor (New)

  • 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-24T11:01:37+00:00Added an answer on May 24, 2026 at 11:01 am

    Try to specify the GroupStyle.Panel in your DataGrid. The reason for this is the fact that the default GroupStyle.Panel (StackPanel) does not fit for the DataGrid Width “*” and the columns will collapse.

    <GroupStyle.Panel>
      <ItemsPanelTemplate>
        <DataGridRowsPresenter/>
      </ItemsPanelTemplate>
    </GroupStyle.Panel>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a collection of custom data objects that I display in DataGrid. The
I have a Silverlight DataGrid that contains a single template column which displays a
We have a Flex DataGrid with 3 columns of which one of them has
I have an Accordion control to which I have added a datagrid. The problem
I have a DataGrid that I use to display an inbox of information. I
I have a DataGrid which uses an itemRenderer to display the items in a
I have found that datagrid columns can be dynamically created and bound in Silverlight.
I am using Displaytag to display the DataGrid. Now, I have to change the
I have a datagrid which has several static and more dynamicaly generated coloumns. The
I have a DataGrid. In the DataGrid's AutoGeneratingColumn event I have some code that

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.