VS11:
Http://www.microsoft.com/click/services/Redirect2.ashx? CR_CC = 200098114
1Win8 MetroUnderMessageBox
Private async void No_But_Click (object sender, RoutedEventArgs e) {MessageDialog msg = new MessageDialog ("are you sure you want to exit your application? "," Gui suwei prompt "); msg. commands. add (new UICommand ("yes", new UICommandInvokedHandler (this. commandInvokedHandler); msg. commands. add (new UICommand ("no", new UICommandInvokedHandler (this. commandInvokedHandler); await msg. showAsync ();} private void CommandInvokedHandler (IUICommand command) {this. dispatcher. invoke (Windows. UI. core. coreDispatcherPriority. normal, (s, a) =>{ UserName_TB.Text = command. label;}, this, null );}
2
Eliminate
AppBarBlock<AppBar Name = "pb" verticalignment = "Bottom" placement = "Stretch" Height = "88" VerticalContentAlignment = "Stretch" Background = "# E5058AE6" Visibility = "Collapsed"> <grid> <Grid. columnDefinitions> <ColumnDefinition/> </Grid. columnDefinitions> <StackPanel Grid. column = "1" Orientation = "Horizontal"/> <StackPanel Orientation = "Horizontal"/> </Grid> </AppBar> background code: protected o Verride void OnRightTapped (RightTappedRoutedEventArgs e) {if (! Pb. IsOpen) {pb. Visibility = Visibility. Visible;} else {pb. Visibility = Visibility. Collapsed;} base. OnRightTapped (e );}
3
Image
Attach ImagesImg. Source = new BitmapImage (new Uri ("ms-appx:/Images/a.png", UriKind. RelativeOrAbsolute ));
4
Get camera imagePrivate async void Button_Click_1 (object sender, RoutedEventArgs e)
{CameraCaptureUI camera = new CameraCaptureUI ();
Camera. PhotoSettings. CroppedAspectRatio = new Size (1, 1); // Ratio
Camera. PhotoSettings. Format = CameraCaptureUIPhotoFormat. Png; // image Format
// Dialog. PhotoSettings. CroppedSizeInPixels = new Size (100,150); // fixed Size
StorageFile file = await camera. CaptureFileAsync (CameraCaptureUIMode. Photo );
If (file! = Null)
{
BitmapImage bitmapImage = new BitmapImage ();
Using (IRandomAccessStream fileStream = await file. OpenAsync (Windows. Storage. FileAccessMode. Read ))
{
BitmapImage. SetSource (fileStream );
}
Img. Source = bitmapImage;
Aaa. Content = file. Path;
}}
5
Get camera videoPrivate async void Button_Click_1 (object sender, RoutedEventArgs e) {CameraCaptureUI dialog = new CameraCaptureUI (); dialog. videoSettings. format = CameraCaptureUIVideoFormat. mp4; StorageFile file = await dialog. captureFileAsync (CameraCaptureUIMode. video); if (file! = Null) {IRandomAccessStream fileStream = await file. OpenAsync (Windows. Storage. FileAccessMode. Read); mediaelement. SetSource (fileStream, "video/mp4 ");}}
6
Get the camera video to the programMediaCapture mediaCaptureMgr;
Private async void Button_Click_1 (object sender, RoutedEventArgs e)
{
MediaCaptureMgr = new MediaCapture ();
Await mediaCaptureMgr. InitializeAsync ();
Scenario1Video. Source = mediaCaptureMgr;
Await mediaCaptureMgr. StartPreviewAsync ();
}
7
Obtain system files
FileOpenPicker openPicker = new FileOpenPicker ();
OpenPicker. ViewMode = PickerViewMode. List; // display the file Style
OpenPicker. SuggestedStartLocation = PickerLocationId. PicturesLibrary; // The Image Library is the target path.
OpenPicker. FileTypeFilter. Add (". iso"); // you can specify a file type.
IReadOnlyList <StorageFile> files = await openPicker. PickMultipleFilesAsync (); // get the file
// Display the file
Foreach (StorageFile v in files)
{
Lv. Items. Add (v. Path );
}
This article is from "Gui Su Wei" blog, please be sure to keep this source http://axzxs.blog.51cto.com/730810/810451