I have a user control that exposes a property of type ImageSource. I want to expose this property in Blend so that I can edit it in Blend, rather than specifying the image in code.
Based on what I've Googled, I've added a dependency property, and specified appropriate attributes to expose the property in Blend.
I can see it there, and edit it (as a text field). What I want to do is have a drop down list of available image resources, and a browse button for loading up another image. In other words I want it to behave like the 'Source' property of the 'Image' control.
edit Just as an aside, I've noticed that exposing Alignment or Margin properties behaves as expected, it just seems to be Images that don't work. I'm really stuck on this one and would appreciate help!
My current code looks like:
public static readonly DependencyProperty ImageSourceProperty =
DependencyProperty.Register("ImageSource", typeof(ImageSource), typeof(SmartButton));
[Category("Appearance")]
[Bindable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public ImageSource ImageSource
{
get { return (ImageSource)GetValue(ImageSourceProperty); }
set
{
SetValue(ImageSourceProperty, value);
this.BackgroundImage.Source = value;
}
}