
Hi all,
is it possible to access a properties attributes in a custom property editor? Basically I'm attempting to change the formatting of a DoubleEditBox based upon some custom attributes associated to the property. I've created a custom editor and an associated DataTemplate and linked the two via a component resource key thus:and the DataTemplate:
Now in order to get hold of the IPropertyDataAccessor I created a custom Decorator and exposed the data accessor as a dependency property I could then bind to the ancestor. This all works fine but then I can't access the PropertyDescriptor through the IPropertyDataAccessor (clues in the name maybe!). Any ideas as to how to get to the PropertyDescriptor either through the Decorator or through the custom editor code?
Maybe there's a simpler way to change the editor formatting but unfortunately I need to access the property attributes as these are created through code generation and define certain default behaviour.
Also if I simply place a DoubleEditBox in the above DataTemplate then the property grid does not display the property value. However if I then switch the editor attribute of the property to point directly to a DouleEditBox the value shows up correctly. The property grid is definately using the correct template and calling the custom edito code ok so why no value (seems to work fine for other custom editors I've created)?
Thanks in advance.
Rick
is it possible to access a properties attributes in a custom property editor? Basically I'm attempting to change the formatting of a DoubleEditBox based upon some custom attributes associated to the property. I've created a custom editor and an associated DataTemplate and linked the two via a component resource key thus:
public class DoubleDecimalPlaceEditor : PropertyEditorObject
{
private ResourceKey editorKey = new ComponentResourceKey(typeof(DoubleDecimalPlaceEditor), PropertyEditorKey.DOUBLE_DECIMAL_PLACE_EDITOR);
public override System.Windows.ResourceKey ValueTemplateKey
{
get
{
return this.editorKey;
}
set
{
// not implemented
}
}
}
<DataTemplate
x:Key="{ComponentResourceKey
TypeInTargetAssembly={x:Type pe:DoubleDecimalPlaceEditor}, ResourceId=DoubleDecimalPlaceEditor}">
<pe:DecimalFormatDecorator
DataAccessor="{Binding RelativeSource={RelativeSource AncestorType={x:Type propgrid:IPropertyDataAccessor}}}">
<editors:DoubleEditBox
CheckBoxVisibility="Visible">
</editors:DoubleEditBox>
</pe:DecimalFormatDecorator>
</DataTemplate>
Maybe there's a simpler way to change the editor formatting but unfortunately I need to access the property attributes as these are created through code generation and define certain default behaviour.
Also if I simply place a DoubleEditBox in the above DataTemplate then the property grid does not display the property value. However if I then switch the editor attribute of the property to point directly to a DouleEditBox the value shows up correctly. The property grid is definately using the correct template and calling the custom edito code ok so why no value (seems to work fine for other custom editors I've created)?
Thanks in advance.
Rick