I am a newbie in windows phone app and need to create a small Windows Phone 7 app. The app will perform the following task
-
App Screen has an image “image1′ ,when i press on ‘image1’ it will shows a second image ‘image2’
-
When I press on image2 it will shows image1 and so on
My XAML code
<Button Click="Button_Click">
<Image Source="resourse/image1.jpg"/>
</Button>
C# code
namespace Test
{
public partial class MainPage : PhoneApplicationPage
{
public MainPage()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
// here will shows the 'image2' and also give click event to turn 'image1'
}
}
}
Please help
I would tackle this by having a couple of images in your XAML:
The use of
x:Namecauses visual studio to generate a field for each image. The second image is ‘collapsed’, i.e. hidden.You click handler then does the following:
On each click it toggled the visibility of each image.
This is easier than changing the Source of the image, which involves URIs etc…