Having trouble getting help?
Contact Support
Contact Support
Attached Properties in WPF PropertyGrid
7 May 20212 minutes to read
The PropertyGrid control has support to display the attached properties of SelectedObject.
Show or hide attached properties of SelectedObject
We can show or hide the attached properties of SelectedObject by handling the AutoGeneratingPropertyGridItem event with AutoGeneratingPropertyGridItemEventArgs.Cancel property. Below example shows, how to hide the attached properties using AutoGeneratingPropertyGridItem
event.
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.6*"/>
<ColumnDefinition Width="0.4*"/>
</Grid.ColumnDefinitions>
<syncfusion:PropertyGrid SelectedObject="{Binding ElementName=button}"
AutoGeneratingPropertyGridItem="PropertyGrid_AutoGeneratingPropertyGridItem"/>
<syncfusion:ButtonAdv Name="button"
Label="SelectedObject"
Margin="10"
Height="25"
Width="200"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Grid.Column="1"
syncfusion:SkinStorage.VisualStyle="Default" />
</Grid>
private void PropertyGrid_AutoGeneratingPropertyGridItem(object sender, AutoGeneratingPropertyGridItemEventArgs e)
{
if (e.DisplayName == "Grid.Column" || e.DisplayName == "SkinStorage.VisualStyle")
{
e.Cancel = true;
}
}
Here, Grid.Column
and SkinStorage.VisualStyle
are the attached properties of SelectedObject.
NOTE
Download demo application from GitHub.