I am trying to set up a dependency property that has an object called Sprite, sprite contains the string spriteSheet, so I want to pass Sprite, and then this data is used to display the image in my control.
This is my attempt as it stands
public Sprite Sprite { get { return (Quiz.Sprite)GetValue(SpriteProperty); } set { spriteBrush.ImageSource = new BitmapImage(new Uri("/Project;component/" + value.spriteSheet, UriKind.RelativeOrAbsolute)); spriteTransform.TranslateX = -558; spriteTransform.TranslateY = 0; SetValue(SpriteProperty, value); } } public static DependencyProperty SpriteProperty = DependencyProperty.Register( "Sprite", typeof(Sprite), typeof(spriteView), new PropertyMetadata(new Quiz.Sprite() { spriteSheet = "wp7_buttons.png" })); }
How do I get that part of the running set method, as I read in the Dependency Property docs, that SetValue and GetValue can be called directly when bound.
source share