
Hi,
I am trying to implement a BrushPropertyEditor at the property level, I would like to dynamically add object properties at runtime. I seem to be missing something. Here is a code snippet:
public partial class MainWindow : Window
{
myObject obj = new myObject { MyBrush = Brushes.Silver };
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
propertyGrid1.SelectedObject = obj;
}
}
public class myObject
{
[Category("Colors")]
[DisplayName("SomeColor")]
[Editor (typeof(BrushPropertyEditor), typeof(PropertyEditor))]
public Brush MyBrush { get; set; }
}
What am I missing? I have also tried to add the BrushPropertyEditor to the PropertyGrid PropertyEditors:
<propgrid:PropertyGrid Height="272" HorizontalAlignment="Left" Margin="116,103,0,0" Name="propertyGrid1" VerticalAlignment="Top" Width="211">
<propgrid:PropertyGrid.PropertyEditors>
<propgrid:BrushPropertyEditor PropertyName="MyBrush"/>
</propgrid:PropertyGrid.PropertyEditors>
</propgrid:PropertyGrid>
All I really want to do is use a ColorEditor in the PropertyGrid for all the Brush color properties that the object may have. The PropertyGrid does not get populated until the user selects the object at runtime, so everything needs to be done in the code behind. I know that there are several other ways to do this, but the property level definition seemed like the easiest.
Thanks,
Jerry