how to dynamically change image source in a silverlight for windows phone 7 project? -


I am working with Silverlight on a Windows Phone 7 project, and I try to show 4 images in sequence I am giving the user a feeling of a short film. I have four urls which point to 4 different JPG images, and I am using an image control to show these JPEGs in sequence. The way I'm trying to achieve it is:

  Private Zero Recover Images () {image1.ImageOpened + = New Event Handler & lt; Routing Aventurugs & gt; (Image1_ImageOpened); Framenumber = 0; GotoNextImage (); } Zero Image 1_ImageOpened (Object Sender, RoutedEventArgs e) {System.Threading.Thread.Sleep (400); GotoNextImage (); } Private Wide Goto Naked Image (if (framenumber & lt; 4) {webBrowser1.Dispatcher.BeginInvoke ((=) => {image1.Source = New System.} Windows Media.imaging.bitmap image (new Uri Camera.frame user [frame number]); frame number ++;});} and (image1.ImageOpened - = image1_ImageOpened;}}  

but it does not work as expected I'm sure I'm missing something about how to interact with the UI, can someone show me the right direction? What is this? What is the best way to do it?

Edit:

I will explain what is wrong in my code ... maybe it is not clear what happens. I have not found any errors with this, but I do not even see the "Movie effect", it only shows a single image, without the image collection running. I think this is a threading problem ... as the UI update To update as expected i co I'm not doing the right thing in the thread ...

this is the best thing to do speed .

xaml

  & lt; UserControl xmlns = "http://schemas.microsoft com / winfx / 2006 / xaml / presentation" xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml" xmlns: d = "http : //schemas.microsoft.com/expression/blend/ 2008 "xmlns: mc =" http://schemas.openxmlformats.org/markup-compatibility/2006 "MC: Ignorable =" d "x: class =" YourNamspace. YourClass "D: DesignWidth =" 24 "D: DesignHight =" 24 "& gt; & Lt; Grid X: Name = "Layouts" & gt; & Lt; Image name = "YourImageName" Stretch = "fill" source = "YourPath" ImageOpened = "onImageOpened" /> & Lt; / Grid & gt; & Lt; / UserControl & gt;  

C #

  using the system; Using System.Windows; Using System.Windows.Controls; Using System.Windows.Documents; Using System.Windows.Ink; Using System.Windows.Input; System.Windows.Media; System.Windows.Media Using imaging; Using System.Windows.Media.Animation; Using System.Windows.Shapes; Using System.Threading; Namespace YourNameSpace {Public partial class YourClass: UserControl {public int FirstImageIndex = 1; Public int LastImageIndex = 1000; Public IT Current Image Index = 1; Public YourClass () {InitializeComponent (); } Private Wide On Image Oppen (Object Sender, System. Windows Routed Avenger ARG E) {Thread. Sleep (1000); Current Image Index = (Current Image Index == Last Image Index)? First Image Index: Current Image Index ++; YourImageName.Source = New Bitmap Image (New Uri ("Your / Path / Copy" + Present ImageInx + ".Jpg"), Uricund.relative orsolute); }}}  

Hope that helps me to be very new to Silverlight.


Comments