Problem with column widths

Grids for WPF Forum

Posted 10 years ago by Phil Devaney - Senior Software Engineer, Serck Controls Ltd
Version: 9.1.0500
Platform: .NET 3.5
Environment: Windows Vista (64-bit)
Avatar
I have an extensively restyled property grid and have noticed that sometimes some rows will have a different width for the name column than all the others. It only seems to happen on the first layout pass - if the property grid is resized then the columns are resized so they are all the same width.

This can be reproduced with the default style in a wizard generated project - simply paste the following into Window1.xaml:

<Window x:Class="WpfApplication1.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:g="http://schemas.actiprosoftware.com/winfx/xaml/propgrid"
        Title="Window1" 
        SizeToContent="WidthAndHeight" 
        WindowStartupLocation="CenterScreen">
  
  <StackPanel Margin="5">
    <g:PropertyGrid SelectedObject="{Binding ElementName=button}" 
                    MaxHeight="500" 
                    IsSummaryVisible="False" />
    <Button x:Name="button" 
            Content="Target Button" 
            Margin="0,10,0,0" />
  </StackPanel>
</Window>
Some of the affected rows include:
- KeyboardNavigation.ControlTabNavigation
- KeyboardNavigation.DirectionalNavigation
- Background
- CommandBindings

As soon as the window is resized all rows jump to the same width.

I have sent a screenshot of the problem to support.

Comments (1)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Phil,

This is a known issue with the native WPF Grid control, which the PropertyGrid uses internally. Specially, it uses a shared size scope, which doesn't work correctly when using * column sizes and you don't give a fixed width.

The only current work around is to set the Width on the Window and change SizeToContent to be Height only. The Window can be resized latter, as you've seen.


Actipro Software Support

The latest build of this product (v2018.1 build 0675) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.