Margin can't be modified in AdvancedTextBlock inside PropertyGridItem

Grids for WPF Forum

Posted 2 years ago by Guillaume Guimond-Croteau
Version: 19.1.3
Platform: .NET 5.0
Environment: Windows 11 (64-bit)


I am trying to modify the PropertyStyle, but I can't manage to modify the Margin of the AdvancedTextBlock. Here is the code:

                        <Style TargetType="grids:PropertyGridItem">
                                <Style TargetType="shared:AdvancedTextBlock">
                                    <Setter Property="Margin" Value="0" />
                                    <Setter Property="Foreground" Value="Blue" />

To test that the TargetType works I also changed the foreground color. It changed correctly, but the margin is still not changing from the orininal 5,3,1,3. Is it a bug or is there something I can do to work around this?

[Modified 2 years ago]

Comments (1)

Answer - Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA


The default value of the PropertyGrid.DefaultStringNameTemplate property is:

	<shared:AdvancedTextBlock x:Name="textBlock" Margin="5,3,1,3" Text="{Binding DisplayName}" 
								TextTrimming="CharacterEllipsis" VerticalAlignment="Center" />
		<DataTrigger Binding="{Binding IsReadOnly}" Value="True">
			<Setter TargetName="textBlock" Property="Opacity" Value="0.7" />

I'd recommend just changing that DataTemplate property value, since your Style won't override the explictly set Margin in that DataTemplate.

Actipro Software Support

The latest build of this product (v24.1.2) 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.