Columns property shared among all PropertyGrids

Grids for WPF Forum

Posted 10 years ago by wpf.acp
Version: 9.1.0505
Platform: .NET 3.5
Environment: Windows Vista (32-bit)
Avatar
As suggested in a past thread I have tried adding a third column to a property grid in order to place a button there with custom functionality. I was puzzled to discover that all property grids appear to somehow share Columns property. To be certain this has nothing to do with my app, I have created a sample reproducing this issue. Please find code/XAML below. The app creates two grids side by side bound to two different Rects. Button click adds a single column to the left grid and the other grid is also affected in the same way.

Is this really by design? And if so, why and how can one add a column to a particular property grid? Thanks!
<Window x:Class="PropertyGridProblem.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:PropertyGrid="clr-namespace:ActiproSoftware.Windows.Controls.PropertyGrid;assembly=ActiproSoftware.PropertyGrid.Wpf30"
        Title="Window1" Height="300" Width="300"
        SizeToContent="WidthAndHeight">
    <Window.Resources>
        <Rect x:Key="rect1"
              X="10" Y="20" Width="123" Height="456" />
        <Rect x:Key="rect2"
              X="0.10" Y="0.20" Width="0.123" Height="0.456" />
    </Window.Resources>
    
    <StackPanel>
        <Button Click="Button_Click">Add Column To Left Grid</Button>
        <UniformGrid Columns="2">
            <PropertyGrid:PropertyGrid x:Name="_grid1"
                                       SelectedObject="{StaticResource rect1}">
            </PropertyGrid:PropertyGrid>
            <PropertyGrid:PropertyGrid x:Name="_grid2"
                                       SelectedObject="{StaticResource rect2}">
            </PropertyGrid:PropertyGrid>
        </UniformGrid>
    </StackPanel>
</Window>

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            _grid1.Columns.Add(new TreeListViewColumn
                                   {
                                       Width = new GridLength(20, GridUnitType.Pixel),
                                       IsResizable = true
                                   });
        }

Comments (1)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Thanks for the bug report, and no this wasn't the intended behavior. The "default" columns were defined using the default Style, which is shared across all PropertyGrids (thus sizing in one instance, would size all).

This has been fixed for the next maintenance release.


Actipro Software Support

The latest build of this product (v2019.1 build 0681) was released 13 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.