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

New Post: Property Grid: Displaying enums in combobox

$
0
0
Hi,

You can find the Style for the default editor of a type Enum in
-Xceed.Wpf.Toolkit/PropertyGrid/Themes/Aero2.NormalColor.xaml (for Windows 8)
-Xceed.Wpf.Toolkit/PropertyGrid/Themes/Generic.xaml ( for other Windows )
It is the style targeting the type "PropertyGridEditorComboBox", which is based on the default ComboBox. So nothing special about it, except using a transparent background/BorderBrush when not focused.

Also, the "Plus" edition of the toolkit supports Localization with Localization attributes. You can have a look at the sample "Data/PropertyGrid/Using SelectedObjects/Localization" available in the "LiveExplorer App" that you can find on this page : https://wpftoolkit.codeplex.com/. Have a look and see if it fills your needs.

In the meantime, here's an idea based on your code snippet:
<Window.Resources>
      <x:Array x:Key="comboSource1"
               Type="sys:String">
         <sys:String>First</sys:String>
         <sys:String>Second</sys:String>
         <sys:String>Third</sys:String>
         <sys:String>Fourth</sys:String>
      </x:Array>
   </Window.Resources>
    
<Grid>
      <xctk:PropertyGrid x:Name="_propertyGrid"
                         SelectedObject="{Binding}">
         <xctk:PropertyGrid.EditorDefinitions>
            <xctk:EditorTemplateDefinition TargetProperties="{x:Type sys:Enum}">
               <xctk:EditorTemplateDefinition.EditingTemplate>
                  <DataTemplate>
                     <ComboBox ItemsSource="{StaticResource comboSource1}"
                               IsEditable="True">
                     </ComboBox>
                  </DataTemplate>
               </xctk:EditorTemplateDefinition.EditingTemplate>
            </xctk:EditorTemplateDefinition>
         </xctk:PropertyGrid.EditorDefinitions>
      </xctk:PropertyGrid>
   </Grid>
</Window>

Viewing all articles
Browse latest Browse all 4964

Trending Articles



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