locked
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!  :-)

    Thanks,

    Jeff

    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#?

    ~Christine

    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:Interaction.Triggers>
    				<i:EventTrigger EventName="MouseLeftButtonDown">
    					<ei:ChangePropertyAction PropertyName="Source">
    						<ei:ChangePropertyAction.Value>
    							<ImageSource>images/musicNote2.png</ImageSource>
    						</ei:ChangePropertyAction.Value>
    					</ei:ChangePropertyAction>
    				</i:EventTrigger>
    			</i:Interaction.Triggers>
    		</Image>

    ...

    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"?

    Thanks,

    Jeff

    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?

    Thanks,

    Jeff

    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