wpf-403662-controls-and-libraries-property-grid-bind-to-property-grid-in-xaml.md
Use the PropertyGridHelper class to bind to a DevExpress.Xpf.PropertyGrid and its elements. The PropertyGridHelper class has the following attached properties:
The following XAML snippet illustrates how to use the PropertyGridHelper to customize the DescriptionTemplate:
The example below illustrates how to use the PropertyGridHelper to change the editor’s cell background color conditionally:
You can use the PropertyGridHelper in code-behind. The example below illustrates how to add OK and Cancel buttons to a Property Grid’s editor:
<dxprg:PropertyDefinition Path="*">
<dxprg:PropertyDefinition.EditSettings>
<dxe:ButtonEditSettings AllowDefaultButton="False" ValidateOnEnterKeyPressed="False" ValidateOnTextInput="False">
<dxe:ButtonEditSettings.Buttons>
<dxe:ButtonInfo GlyphKind="Apply" Click="ApplyButtonClicked" />
<dxe:ButtonInfo GlyphKind="Cancel" Click="CancelButtonClicked" />
</dxe:ButtonEditSettings.Buttons>
</dxe:ButtonEditSettings>
</dxprg:PropertyDefinition.EditSettings>
</dxprg:PropertyDefinition>
private void ApplyButtonClicked(object sender, RoutedEventArgs e) {
PropertyGridHelper.GetPropertyGrid((DependencyObject)sender).CloseEditor();
}
private void CancelButtonClicked(object sender, RoutedEventArgs e) {
PropertyGridHelper.GetPropertyGrid((DependencyObject)sender).HideEditor();
}
Private Sub ApplyButtonClicked(ByVal sender As Object, ByVal e As RoutedEventArgs)
PropertyGridHelper.GetPropertyGrid(DirectCast(sender, DependencyObject)).CloseEditor()
End Sub
Private Sub CancelButtonClicked(ByVal sender As Object, ByVal e As RoutedEventArgs)
PropertyGridHelper.GetPropertyGrid(DirectCast(sender, DependencyObject)).HideEditor()
End Sub