Posted May 16, 2011
I'm having trouble getting full screen images to load in a winphone7 application I'm building for a uni assignment and was hoping some of the lads/lasses/other here could help.
I'm trying to create a basic image gallery view and have set up the thumbnails as buttons in my .xaml page and that part works perfectly, they display the images and respond to clicks correctly. My objective is to have a grid of thumbnail images and when the user taps one, he gets a fullscreen display of the large version of the image and can close that with a screen tap or by hitting back.
I've managed to figure out how to use global variables and get them populating correctly, the problem I'm having now is how to change the image source based on the variable (which is populated by the on-click function of the button on the previous page). For example I want to have the variable contain the name of the selected image (pic1.jpg) and have the image reference in the xaml change based on the variable <image name="pic" source="/project;component/images/<VARIABLE DATA>". I eventually want to have it populate from a remote server but local will do fine for the moment as long as it bloody works in time for me to hand the project in.
The tricky thing is that I'm trying to do it across different pages (gallery.xaml & fullscreenimage.xaml) and I can't get the image tag to update its source based on the global variable.
I've set up my global variable in app.xaml on the theory that every page would have access to it, as far as I know making a public class to contain the variable in a page restricts it to that page.
IN APP.XAML.CS - Global variable
Anyone got any ideas?
I'm trying to create a basic image gallery view and have set up the thumbnails as buttons in my .xaml page and that part works perfectly, they display the images and respond to clicks correctly. My objective is to have a grid of thumbnail images and when the user taps one, he gets a fullscreen display of the large version of the image and can close that with a screen tap or by hitting back.
I've managed to figure out how to use global variables and get them populating correctly, the problem I'm having now is how to change the image source based on the variable (which is populated by the on-click function of the button on the previous page). For example I want to have the variable contain the name of the selected image (pic1.jpg) and have the image reference in the xaml change based on the variable <image name="pic" source="/project;component/images/<VARIABLE DATA>". I eventually want to have it populate from a remote server but local will do fine for the moment as long as it bloody works in time for me to hand the project in.
The tricky thing is that I'm trying to do it across different pages (gallery.xaml & fullscreenimage.xaml) and I can't get the image tag to update its source based on the global variable.
I've set up my global variable in app.xaml on the theory that every page would have access to it, as far as I know making a public class to contain the variable in a page restricts it to that page.
IN APP.XAML.CS - Global variable
public class FullscreenImage
{
public static string picsource="";
}
IN GALLERY.XAML.CS - for the button click in the gallery page {
public static string picsource="";
}
private void pic1_click(object sender, RoutedEventArgs e)
{
FullscreenImage.picsource = "Pic1.jpg";
NavigationService.Navigate(new Uri("/Fullscreenpic.xaml", UriKind.Relative));
}
IN FULLSCREEN.XAML - For the actual image placeholder I'm trying to dynamically alter {
FullscreenImage.picsource = "Pic1.jpg";
NavigationService.Navigate(new Uri("/Fullscreenpic.xaml", UriKind.Relative));
}
<Image Name="FullscreenPic" Source="" Height="800" Margin="14,0,-1,0" />
From what I've researched I get the impression that I'm supposed to be using data binding but I can never find a tutorial that I can understand, they're either written for people who already know C# (I'm trying to teach myself and I'm a crap teacher) or are doing more complicated things like binding to a database which is a lot more than I want to do for the short term. Anyone got any ideas?
Post edited May 16, 2011 by Aliasalpha
This question / problem has been solved by Gersen