What is not working ?
From using your code snippet, I build a working sample.
Upon executing, I can see the propertyGrid with 1 property displaying its editor as you defined it in XAML.
From using your code snippet, I build a working sample.
Upon executing, I can see the propertyGrid with 1 property displaying its editor as you defined it in XAML.
<Window x:Class="WpfApplication4.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:local="clr-namespace:WpfApplication4"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<xctk:PropertyGrid x:Name="_propertyGrid"
SelectedObject="{Binding}">
<xctk:PropertyGrid.EditorDefinitions>
<xctk:EditorTemplateDefinition>
<xctk:EditorTemplateDefinition.TargetProperties>
<xctk:TargetPropertyType Type="{x:Type local:myClass}" />
</xctk:EditorTemplateDefinition.TargetProperties>
<xctk:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<Grid VerticalAlignment="Center"
HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Background="{Binding Value.Brush}"
Text="{Binding Value.Name}" />
<Button Grid.Column="1"
Content=". . ."
FontSize="9"
FontWeight="Bold"
VerticalAlignment="Top"
Width="25"
Height="15"/>
</Grid>
</DataTemplate>
</xctk:EditorTemplateDefinition.EditingTemplate>
</xctk:EditorTemplateDefinition>
</xctk:PropertyGrid.EditorDefinitions>
</xctk:PropertyGrid>
</Grid>
</Window> public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.DataContext = new ContextClass();
}
}
public class ContextClass
{
public ContextClass()
{
this.MyObject = new myClass() { Brush = Brushes.Green, Name = "Bob" };
}
public myClass MyObject
{
get;
set;
}
}
public class myClass : DependencyObject
{
public static readonly DependencyProperty BrushProperty = DependencyProperty.Register( "Brush", typeof( Brush ), typeof( myClass ) );
public Brush Brush
{
get
{
return ( Brush )GetValue( BrushProperty );
}
set
{
SetValue( BrushProperty, value );
}
}
public static readonly DependencyProperty NameProperty = DependencyProperty.Register( "Name", typeof( string ), typeof( myClass ) );
public string Name
{
get
{
return ( string )GetValue( NameProperty );
}
set
{
SetValue( NameProperty, value );
}
}
}