Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: Limit PropertyGrid Control Standard Properties and Use Toolkit ColorPickerEditor

$
0
0
Hi,

First, "EditorDefinition" is obsolete, you should use "EditorTemplateDefinition". You can bind the PropertyGridEditorColorPicker.SelectedColor to the Value of the EditorTemplateDefinition without code-behind. You only need to use the SolidColorBrushToColorConverter. Here's how to do it :
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"

 <Window.Resources>
      <xctk:SolidColorBrushToColorConverter x:Key="SolidColorBrushToColorConverter1" />
   </Window.Resources>
    
   <Grid>
      <StackPanel>
         <Ellipse x:Name="_ellipse"
                  Fill="Green"
                  Width="150"
                  Height="150" />
         
         <xctk:PropertyGrid x:Name="_propertyGrid"
                            AutoGenerateProperties="False"
                            SelectedObject="{Binding ElementName=_ellipse}">
            <xctk:PropertyGrid.PropertyDefinitions>
               <xctk:PropertyDefinition TargetProperties="Fill" />
            </xctk:PropertyGrid.PropertyDefinitions>
            
            <xctk:PropertyGrid.EditorDefinitions>
               <xctk:EditorTemplateDefinition TargetProperties="Fill">
                  <xctk:EditorTemplateDefinition.EditingTemplate>
                     <DataTemplate>
                        <xctk:PropertyGridEditorColorPicker SelectedColor="{Binding Value, Converter={StaticResource SolidColorBrushToColorConverter1}}"
                                                            DisplayColorAndName="True"/>
                     </DataTemplate>
                  </xctk:EditorTemplateDefinition.EditingTemplate>
               </xctk:EditorTemplateDefinition>
            </xctk:PropertyGrid.EditorDefinitions>

         </xctk:PropertyGrid>
      </StackPanel>
   </Grid>

Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>