Can I change default size of columns in PropertyGrid ?

Default ratio is 50:50. I know there did not use to be support for changing this.
Is that still true ?

I can of course resize the columns after display using the splitter

9 Replies

MJ Mythily Jega Jothi Syncfusion Team July 23, 2018 12:33 PM UTC

Hi Steve,

In our PropertyGrid, you can resize the column using mouse in run time.
But there is no support to resize the column programmatically. Can you please let us know the why you need to change the column size while loading. Based on your update, we will analyze and update you the details.

Regards,
Mythily J


SM Steve McWilliams July 23, 2018 02:12 PM UTC

I've attached pics of the way the grid looks initially vs. the way I'd like it to look, so the user doesn't have to resize it manually all the time.
But, if it can't be done, that's fine.

Attachment: Desktop_82477c78.zip


MJ Mythily Jega Jothi Syncfusion Team July 24, 2018 12:28 PM UTC

Hi Steve,

Thanks for your update.

Currently, PropertyGrid does not have support for resize the column width programmatically. We have logged this requirement as a feature request. We will implement this feature in any of our upcoming releases.

Regards,
Mythily J


NV NM van Strien July 7, 2020 09:45 PM UTC

Has this feature been implemented for the propertygrid (i.e. programmatically resize of column width). I cannot find it in the documentation, but am also not sure it is there.

Kind regards,

Niels van Strien


AI Anirudhan Iyyappan Syncfusion Team July 9, 2020 09:08 AM UTC

Hi NM van Strien 
 
Thank for your patience.                      
 
We have achieved your requirement by customizing the PropertyViewItem template. Please refer to the screenshot, code snippet and the sample below for further references.   
 
Code snippet:  
 
<Grid x:Name="ViewGrid">  
    <Grid.ColumnDefinitions>  
        <ColumnDefinition MinWidth="44" Width="100" />  
        <ColumnDefinition Width="1" />  
        <ColumnDefinition MinWidth="44" Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ResizeColumn2, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />  
    </Grid.ColumnDefinitions>  
 <Border x:Name="Border" Background="{TemplateBinding Background}" SnapsToDevicePixels="True" >  
      <Grid Margin="{Binding PropertyLevel, Mode=OneWay, Converter={StaticResource LevelConverter}}" >  
              <Grid.ColumnDefinitions>  
                       <ColumnDefinition Width="auto" x:Name="expanderColumn"/>  
                         <ColumnDefinition Width="*"/>  
                 </Grid.ColumnDefinitions>  
<ContentPresenter Margin="{TemplateBinding Padding}" Grid.Column="1" x:Name="PART_Content" ContentTemplate="{TemplateBinding EditorTemplate}" Content="{TemplateBinding HeaderedItemsControl.Header}" />  
        </Grid>  
</Border>  
 <GridSplitter IsTabStop="False" Width="1" Background="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" HorizontalAlignment="Stretch" Grid.Column="1" />  
<ContentPresenter Grid.Column="2" x:Name="PART_Content1" ContentTemplate="{StaticResource PropertyValueTemplate}" Content="{TemplateBinding HeaderedItemsControl.Header}" />  
</Grid>  
 
 
 
 
Screenshot:    
 
     
 
 
Please let us know if you need any further assistance on this. We are happy to help you as always.  
 
Regards,   
Anirudhan 



NV NM van Strien July 10, 2020 05:50 PM UTC

Hi Anirudhan,

Thank you for showing this solution - it is very interesting and I may use it as a way forward for now. I do however feel that it introduces a lot of code that I am  unfamiliar with for one change and fear that I am introducing the risk for errors  by importing 'magic code' that I don't fully master myself..

I tried to copy the PropertyViewItem template from your demo into my project, but I am getting 18 errors and it overrides the sfskin:SfSkinManager.VisualStyle="Blend" option that I am using. I am getting errors like the one below - missing static resources. I have looked for any project references I might miss, but I could not find the cause. Still,  it causes runtime errors.

Severity    Code    Description    Project    Line    Suppression State    File
Error    XDG0062    The resource "ViewForeground" could not be resolved.   

Rebuilding the project does not solve these missing references.

I noticed that in the code defined just after the x:Name="ViewGrid" property in the template, changing the width parameter does in fact what I would like to do - it changes the width of the first column and adjusts the width of the second column.

<Grid x:Name="ViewGrid">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition MinWidth="44" Width="400" />


Would it be possible to introduce a variable for this, as requested by the original author of this post, so that the user can simply say FirstColumnWidth when declaring a propertygrid in xaml? E.g.

<syncfusion:PropertyGrid
 x:Name="Demo"
FirstColumnWidth="300"/> (or whatever value you specify)

I understand there are many feature requests and not all can be implemented, so any help to solve the missing resources issues I encountered is also very welcome.

Kind regards,

Niels




AI Anirudhan Iyyappan Syncfusion Team July 13, 2020 01:03 PM UTC

Hi NM van Strien, 
 
Thanks for your update. 
 
We can the resolve this issue using the BlendPropertyGridStyle Template instead of DefaultPropertyGridStyle and please add the below code snippet in you App.xaml to resolve those error. For further references please refer to the below sample and code snippet. 
 
Code snippet: 
 
 
<Application.Resources> 
        <ResourceDictionary> 
            <ResourceDictionary.MergedDictionaries> 
                <ResourceDictionary Source="/Syncfusion.PropertyGrid.WPF;component/Themes/BlendStyle.xaml"/> 
            </ResourceDictionary.MergedDictionaries> 
        </ResourceDictionary> 
</Application.Resources> 
 
 
 
 
Regards, 
Anirudhan 



GG GGGW replied to Anirudhan Iyyappan July 6, 2021 08:45 PM UTC

Am I the only one getting errors in this example?

Error The resource "ResourceWrapperKey" could not be resolved.

for
ToolTip="{Binding Source={StaticResource ResourceWrapperKey}, Path=PropertyGridCategorizedToolTip}" C:\Projects\transmitter\RA3.0\dotNET\Sandbox\WpfApp6\WpfApp6\MainWindow.xaml 53 82

ToolTip="{Binding Source={StaticResource ResourceWrapperKey}, Path=PropertyGridAlphabeticalToolTip}" C:\Projects\transmitter\RA3.0\dotNET\Sandbox\WpfApp6\WpfApp6\MainWindow.xaml 65 82

WatermarkText="{Binding Source={StaticResource ResourceWrapperKey},Path=Search}" WatermarkTextIsVisible="True" Cursor="IBeam" /> C:\Projects\transmitter\RA3.0\dotNET\Sandbox\WpfApp6\WpfApp6\MainWindow.xaml 71 82

<syncfusion:ClearButton x:Name="PART_Clear" IsTabStop="False" ToolTip="{Binding Source={StaticResource ResourceWrapperKey},Path=Clear}" Background="Transparent" BorderBrush="Transparent" BorderThickness="1" Width="20" Height="20" Visibility="Collapsed" HorizontalAlignment="Right" Margin="1 0" > C:\Projects\transmitter\RA3.0\dotNET\Sandbox\WpfApp6\WpfApp6\MainWindow.xaml 72 148

Searching the solution for "ResourceWrapperKey" and the only results are the 4 error locations.




SN Sudharsan Narayanan Syncfusion Team July 7, 2021 03:22 PM UTC

Hi Gregg,

Thanks for update.

We have resolved this issue
with some modification in sample. Please check the sample from the below location,

Sample: https://www.syncfusion.com/downloads/support/forum/138839/ze/WpfApp6575978106

Regards, 
Sudharsan N

Loader.
Up arrow icon