Mansoor
Mansoor

Reputation: 41

how can i make image clickable in window phone 7

i need help from window phone developer. I am making app in which image source are from internet. I want to navigate to another page which i already added into app by making them in xaml format. Now the issue is that i want to navigate to other page by clicking on image.

my image xaml code is this.

<Image Height="134" HorizontalAlignment="Left" Source="http://www.serversidedesign.com/wp-content/uploads/2011/10/partner5-170x134.jpg" Margin="27,29,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="170"  ImageFailed="image1_ImageFailed" />

mean while the xaml.cs code for this is

private void image1_ImageFailed(object sender, ExceptionRoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.RelativeOrAbsolute));
        }

i am unable to navigate to my other page of app. It would be great if anyone help me. Thanks.

Upvotes: 0

Views: 1213

Answers (1)

Mani
Mani

Reputation: 1374

First thing i observed is that your image cannot be displayed. Source if specified as url, the url kind has to be defined from relative to absolute. And secondly when you want something like a click to it, better to have a button with content="" and background=image source. in the button click you define the navigation procedure.Example code:

<Button Width="200" Click="Image_Click" >
                        <Button.Background>
                            <ImageBrush Stretch="Fill" ImageSource="/Images/99x99.png"/>
                        </Button.Background>
</Button>

In the image_click event define your navigation.

Upvotes: 1

Related Questions