Hi is there a possibility to get access to the dataAccessor from a derived property editor?
public class Father : PersonFull
{
public Father()
{
PossibleChildren = new List<PersonFull>
{
new PersonFull() { FirstName="Julia",Surname="Mustermann"},
new PersonFull() { FirstName="Verena", Surname = "Mustermann"},
new PersonFull() { FirstName="Anita", Surname = "Mustermann"},
new PersonFull() { FirstName="Michael", Surname = "Mustermann"},
new PersonFull() { FirstName="Thomas", Surname = "Mustermann"},
new PersonFull() { FirstName="Bernhard", Surname = "Mustermann"}
};
}
public IList<PersonFull> Children { get; set; }
[Browsable(false)]
public IList<PersonFull> PossibleChildren { get; set; }
public string Name { get; set; }
}
<Editors:PropertyEditor x:Class="ActiproSoftware.Windows.ProductSamples.PropertyGridSamples.QuickStart.Virtualization.SimpleMasterDetailEditor"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Editors="clr-namespace:ActiproSoftware.Windows.Controls.PropertyGrid.Editors;assembly=ActiproSoftware.PropertyGrid.Wpf30"
xmlns:Com="clr-namespace:ActiproSoftware.Windows.ProductSamples.PropertyGridSamples.QuickStart.Virtualization">
<Editors:PropertyEditor.ValueTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<ComboBox Background="Blue" ItemsSource="{Binding AddItems}" SelectedItem="{Binding SelectedItem}"/>
<ListBox Background="Red" ItemsSource="{Binding AddedItems}">
<ListBox.CommandBindings>
<CommandBinding Command="{x:Static Com:Commands.RemoveCommand}" Executed="Remove"/>
</ListBox.CommandBindings>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<ContentPresenter/>
<Button Content="X" Tag="{Binding}" Command="{x:Static Com:Commands.RemoveCommand}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</DataTemplate>
</Editors:PropertyEditor.ValueTemplate>
</Editors:PropertyEditor>
private DataTemplate dataTemplate;
public override DataTemplate ValueTemplate {
get {
if (null == this.dataTemplate) {
FrameworkElementFactory factory = new FrameworkElementFactory(typeof(ContentPresenter));
factory.SetValue(ContentPresenter.ContentProperty, this);
factory.SetValue(ContentPresenter.ContentTemplateProperty, /* set to actual desired DataTemplate */);
this.dataTemplate = new DataTemplate() { VisualTree = factory };
}
return this.dataTemplate;
}
set { /* No-op */ }
}
factory.SetValue(MyBehavior.AttachedProperty1, this);
factory.SetBinding(MyBehavior.AttachedProperty2, new Binding("DataContext") {
RelativeSource = new RelativeSource() { AncestorType = typeof(IPropertyDataAccessor) }
});
Please log in to a validated account to post comments.