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

New Post: UserControl as custom editor

$
0
0
Hi,

Usually, with the current version of the toolkit, we are using the comboBox (as an editor for a propertyItem) this way :
```<Window.Resources>
<x:Array x:Key="comboSource" Type="s:String">
     <s:String>String Value 1</s:String>
     <s:String>String Value 2</s:String>
     <s:String>String Value 3</s:String>
  </x:Array>      
</Window.Resources>
<Grid>
  <xctk:PropertyGrid x:Name="_propertyGrid">
     <xctk:PropertyGrid.EditorDefinitions>
        <xctk:EditorTemplateDefinition TargetProperties="GroupName">
           <xctk:EditorTemplateDefinition.EditingTemplate>
              <DataTemplate>
                 <ComboBox ItemsSource="{StaticResource comboSource}"  SelectedItem="{Binding Value}"/>
              </DataTemplate>
           </xctk:EditorTemplateDefinition.EditingTemplate>
        </xctk:EditorTemplateDefinition>

        <xctk:EditorTemplateDefinition TargetProperties="{x:Type s:String}">
           <xctk:EditorTemplateDefinition.EditingTemplate>
              <DataTemplate>
                 <xctk:WatermarkTextBox Text="{Binding Value}"  SelectAllOnGotFocus="True" />
              </DataTemplate>
           </xctk:EditorTemplateDefinition.EditingTemplate>
        </xctk:EditorTemplateDefinition>

     </xctk:PropertyGrid.EditorDefinitions>
  </xctk:PropertyGrid>
</Grid>

public partial class MainWindow : Window
{
public MainWindow()
{
  Xceed.Wpf.Toolkit.Licenser.LicenseKey = "XXXXX-XXXXX-XXXXX-XXXX";
  InitializeComponent();
  _propertyGrid.SelectedObject = new MyData()
  {
    ID = 12,
    FirstName = "MyFirstName",
    LastName = "MyLastName",
    GroupName = ((string[])this.Resources["comboSource"])[1]
  };
}
}

public class MyData : DependencyObject
{
public int ID  {  get;  set; }

public string FirstName  { get; set; }

public string LastName { get; set; }

public string GroupName  {  get; set;  }
}

Setting an Editor for "stings" after having set an editor for a PropertyItem of type "string" shouldn't cancel the first editor.
Are you trying to do something like that ?

Viewing all articles
Browse latest Browse all 4964

Trending Articles



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