after some search and reading http://wpftoolkit.codeplex.com/wikipage?title=PropertyGrid&referringTitle=Documentation
i think its minimum two ways in my case.
1. Customise xctk:CollectionControl
and edit XAML.
<xctk:PropertyGrid Name="_generalPropertyGrid" DockPanel.Dock="Top"
ShowSearchBox="False" ShowSortOptions="False" ShowTitle="False" NameColumnWidth="120" BorderThickness="0">
<xctk:PropertyGrid.EditorDefinitions>
<xctk:EditorTemplateDefinition TargetProperties="CarsCollection">
<xctk:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<xctk:CollectionControl SelectedItem="{Binding Path=SelectedCar}"/>
</DataTemplate>
</xctk:EditorTemplateDefinition.EditingTemplate>
</xctk:EditorTemplateDefinition>
</xctk:PropertyGrid.EditorDefinitions>
</xctk:PropertyGrid>
2. Create own UserControl
that implements the ITypeEditor
see datails in http://wpftoolkit.codeplex.com/wikipage?title=PropertyGrid&referringTitle=Documentation Select by ComboBox
. i choose this way.
<UserControl x:Class="proj_namespace.CarSelector"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
x:Name="CarSelector"
d:DesignHeight="25" d:DesignWidth="200">
<Grid>
<ComboBox ItemsSource="{Binding Value, ElementName=CarSelector}" SelectionChanged="Selector_OnSelectionChanged"/>
</Grid>
</UserControl>
And class code behind:
public partial class CarSelector : ITypeEditor
{
public CarSelector()
{
InitializeComponent();
}
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value", typeof(ObservableCollection<string>), typeof(CarSelector),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
public string Value
{
get { return (string)GetValue(ValueProperty); }
set { SetValue(ValueProperty, value); }
}
public FrameworkElement ResolveEditor(PropertyItem propertyItem)
{
var binding = new Binding("Value");
binding.Source = propertyItem;
binding.Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay;
BindingOperations.SetBinding(this, ValueProperty, binding);
return this;
}
private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (sender != null)
MainWindow.Instance._properties.SelectedCar = (sender as ComboBox).SelectedItem as string;
}
}
and finally add custom editor line above property
[Editor(typeof(CarSelector), typeof(CarSelector))]
public ObservableCollection<string> CarsCollection { get { return _securities; } }