Windows Phone select photo

Source: Internet
Author: User

App. CS

Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. net;
Using system. windows;
Using system. Windows. controls;
Using system. Windows. documents;
Using system. Windows. input;
Using system. Windows. Media;
Using system. Windows. Media. animation;
Using system. Windows. Media. imaging;
Using system. Windows. Navigation;
Using system. Windows. shapes;
Using Microsoft. Phone. controls;
Using Microsoft. Phone. shell;

Namespace photoapp
{
Public class globaldata
{
Public bitmapimage;
}

Public partial class app: Application
{
Public static globaldata;

/// <Summary>
/// Provides easy access to the root frame of the phone application.
/// </Summary>
/// <Returns> the root frame of the phone application. </returns>
Public phoneapplicationframe rootframe {Get; private set ;}

/// <Summary>
/// Constructor for the Application object.
/// </Summary>
Public app ()
{
Globaldata = new globaldata ();
Globaldata. bitmapimage = new bitmapimage ();

// Global handler for uncaught exceptions.
Unhandledexception + = application_unhandledexception;

......

Mainpage. XAML

Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. net;
Using system. windows;
Using system. Windows. controls;
Using system. Windows. documents;
Using system. Windows. input;
Using system. Windows. Media;
Using system. Windows. Media. animation;
Using system. Windows. shapes;
Using Microsoft. Phone. controls;
Using Microsoft. Phone. tasks;
Using system. Windows. Navigation;

Namespace photoapp
{
Public partial class mainpage: phoneapplicationpage
{
Photochoosertask;

// Constructor
Public mainpage ()
{
Initializecomponent ();
Photochoosertask = new photochoosertask ();
Photochoosertask. Completed + = new eventhandler <photoresult> (photochoosertask_completed );
}

Void photochoosertask_completed (Object sender, photoresult E)
{
If (E. taskresult = taskresult. OK)
{
App. globaldata. bitmapimage. setsource (E. chosenphoto );
// Navigationservice. navigate (New uri ("/photopage. XAML", urikind. Relative ));
Navigationservice. navigated + = new navigatedeventhandler (navigatecompleted );
}
}

Void navigatecompleted (Object sender, eventargs E)
{
// Do the delayed navigation from the main page
This. navigationservice. navigate (New uri ("/photopage. XAML", urikind. Relative ));
Navigationservice. navigated-= new navigatedeventhandler (navigatecompleted );
}

/// <Summary>
/// Select a photo
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "E"> </param>
Private void button#click (Object sender, routedeventargs E)
{
Photochoosertask. Show ();
}

}
}

Photopage. XAML

Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. net;
Using system. windows;
Using system. Windows. controls;
Using system. Windows. documents;
Using system. Windows. input;
Using system. Windows. Media;
Using system. Windows. Media. animation;
Using system. Windows. shapes;
Using Microsoft. Phone. controls;

Namespace photoapp
{
Public partial class photopage: phoneapplicationpage
{
Public photopage ()
{
Initializecomponent ();
}

Protected override void onnavigatedto (system. Windows. Navigation. navigationeventargs E)
{
Base. onnavigatedto (E );
Image1.source = app. globaldata. bitmapimage;
}
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.