0

I'm using a page with a grid with 3 rows where every row contains a groupbox. The groupboxes also contain different grids with different content. I would like to have all of my groupboxes to fit the same width. Initially that's the case. But when the content of the first group box is updated from code behind, the group box gets redrawn for a very short moment (width is smaller), but a second later it again fits to the width. Initially it is: "not connected" which changes to "connected", so width is smaller. The Width of my window is set to maximize, I don't want to set fix width and height for the page and the grids. Is there a way I can only update the content, without the box trying to fit to the content?

Example ( 2 rows):

<Grid Grid.IsSharedSizeScope="True" Name="globalGrid" >
    <Grid.ColumnDefinitions>
        <ColumnDefinition SharedSizeGroup="globalCol"/>          
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition SharedSizeGroup="RowA"/> 
        <RowDefinition SharedSizeGroup="RowA"/>
        <RowDefinition SharedSizeGroup="RowA"/>
    </Grid.RowDefinitions>
    <GroupBox Header="Connection status" 
              Grid.Row="0" Grid.Column="0"
              HorizontalAlignment="Stretch">          
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition />                   
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>             
            <Rectangle Name="Connected"  
                       Style="{StaticResource iconConnectStyle}" 
                       DataContext="{Binding DeviceConnection}" 
                       Grid.Row="0" Grid.Column="0"  />
            <TextBlock Text="device 1:" 
                       Grid.Row="0" Grid.Column="1" 
                       Style="{StaticResource statusText}"/>
            <TextBlock Name="dev1" Grid.Row="0" Grid.Column="2" 
                       Style="{StaticResource statusText}" />                      
        </Grid>
    </GroupBox>

    <GroupBox Header="processing status"  
              Grid.Row="1" Grid.Column="0"
              HorizontalAlignment="Stretch">          
        <StackPanel>
            <TextBlock x:Name="processState" Style="{StaticResource statusText}"/>
            <ProgressBar x:Name="progressState"/>
        </StackPanel>
    </GroupBox>      
</Grid>  
purbsel
  • 307
  • 8
  • 21
  • Depends how you change the content but in the end the result stays as desired even though for a short bit GroupBoxes seem to change width. At least that is how I understood your question. So the question is why woring about this when it works. :) – dev hedgehog Oct 25 '13 at 08:15
  • Yes, it works, but it's not perfect ;-) – purbsel Oct 25 '13 at 09:00
  • Titanic was perfect. And we all know what happened to she. Dont worry about those little details. Dont worry about that behavior. Thats actually normal in wpf. – dev hedgehog Oct 25 '13 at 09:04

1 Answers1

0

I'm now using a UniformGrid, that solved the problem...

purbsel
  • 307
  • 8
  • 21