How to quickly replace an Image with associated behaviors RRS feed

  • Question

  • Hi,

    When I need to update an image in my prototype (switch an old image out for a new, updated image), what is the easiest and quickest way to replace it so that all associated behaviors with the old image are switched to the new image? 

    Please tell me there is a better way than manually updating all the behaviors!  :-)



    Thursday, April 5, 2012 7:24 PM

All replies

  • Hi Jeff,

    And sorry for calling you Jim yesterday. :)

    Do you mean changing them in design and not losing behaviors?  If so simply changing the source will work.  Your associated behaviors will still stay on the image object.

    If you mean changing them at run time, from code behind or by using a ChangePropertyAction, are you working in Silverlight Sketchflow or WPF Sketchflow?  Do you want to change from code or using a behavior?  If code is it C#?


    Here is an example of changing at run time with the ChangePropertyAction Behavior...

    <Image x:Name="myImage" HorizontalAlignment="Left" Height="36" Source="images/musicNote.png" Stretch="Fill" VerticalAlignment="Top" Width="36">
    				<i:EventTrigger EventName="MouseLeftButtonDown">
    					<ei:ChangePropertyAction PropertyName="Source">


    Or from code behind...

    WPF - C# Code-Behind for on MouseLeftButtonDown event...

    private void mySecondImage_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
    			mySecondImage.Source = new BitmapImage(new Uri("images/musicNote2.png", UriKind.RelativeOrAbsolute));

    Thursday, April 5, 2012 10:06 PM
  • Hi Christine,

    Yes, I just want to change in design without losing behavior.

    I am now trying to use the "Source" field, but the problem I am having is my Source drop down just says "Image1", "Image2", etc. 

    I rename all images when I paste them on the art board (so I can keep track of them). 

    How can I see the renamed image name in the Source drop down instead of "Image1"?



    Monday, April 9, 2012 5:43 PM
  • Hi Christine,

    Even though "Image#" is shown instead of what I renamed it to, I am able to choose the correct source image.

    When I add a new image, and then select the old image as the source for the new image, the behaviors for the old image are not transferred to the new image.

    What am I doing wrong?



    Monday, April 9, 2012 6:29 PM
  • Ok, I figured it out.  I was trying to make the source for the new image the old image instead of the other way around.  Thanks!

    • Proposed as answer by Christine L. _ Tuesday, April 10, 2012 12:46 AM
    Monday, April 9, 2012 10:05 PM