自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Windows Phone開發(fā)(26):啟動器與選擇器之五

移動開發(fā)
Windows Phone是微軟發(fā)布的一款手機(jī)操作系統(tǒng),它將微軟旗下的Xbox Live游戲、Xbox Music音樂與獨特的視頻體驗整合至手機(jī)中。

啟動器與選擇器簡單的地方在于,它們的使用方法幾乎一模一樣,從前面幾節(jié)中,我相信大家基本上都知道如何使用它們了。
這里還是哆嗦一下吧,使用啟動器和選擇器的步驟如下:
1、實例化,new一個;
2、準(zhǔn)備各參數(shù),對相關(guān)的屬性賦值;
3、Show;
4、對于啟動器,不需要這步,但選擇器有返回數(shù)據(jù),所以需要處理完成事件。

本節(jié)再舉兩例子,啟動器和選擇器就可以完成了,然后我們下一節(jié)開始,探討新的知識點。

例一:媒體播放器。

這是一個啟動器,用起來更方便。
主要屬性有:
Controls——要顯示控制按鈕,如暫集,停止等,它是一個帶了Flags特性標(biāo)記的枚舉,所以可以多個值合并,如MediaPlaybackControls.Pause | MediaPlaybackControls.Stop

Location——要播放媒體的位置,Data表示文件存放在獨立存儲中,Install表示項目中的媒體文件;

Media——要播放文件的URI;

Orientation——這個更好懂了,媒體播放器的方向, 是水平還是垂直,和頁面方向一個概念。

  1. <phone:PhoneApplicationPage    
  2.     x:Class="sampleApp.MainPage"   
  3.     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   
  4.     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   
  5.     xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"   
  6.     xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"   
  7.     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"   
  8.     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"   
  9.     mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"   
  10.     FontFamily="{StaticResource PhoneFontFamilyNormal}"   
  11.     FontSize="{StaticResource PhoneFontSizeNormal}"   
  12.     Foreground="{StaticResource PhoneForegroundBrush}"   
  13.     SupportedOrientations="Portrait" Orientation="Portrait"   
  14.     shell:SystemTray.IsVisible="True">   
  15.     <!--LayoutRoot 是包含所有頁面內(nèi)容的根網(wǎng)格-->   
  16.     <Grid x:Name="LayoutRoot" Background="Transparent">   
  17.         <Grid.RowDefinitions>   
  18.             <RowDefinition Height="Auto"/>   
  19.             <RowDefinition Height="*"/>   
  20.         </Grid.RowDefinitions>   
  21.         <!--TitlePanel 包含應(yīng)用程序的名稱和頁標(biāo)題-->   
  22.         <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">   
  23.             <TextBlock x:Name="ApplicationTitle" Text="我的應(yīng)用程序" Style="{StaticResource PhoneTextNormalStyle}"/>   
  24.             <TextBlock x:Name="PageTitle" Text="頁面名稱" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>   
  25.         </StackPanel>   
  26.         <!--ContentPanel - 在此處放置其他內(nèi)容-->   
  27.         <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">   
  28.             <Button Content="啟動媒體播放器" Height="126" HorizontalAlignment="Left" Margin="31,116,0,0" Name="button1" VerticalAlignment="Top" Width="381" Click="button1_Click" />   
  29.         </Grid>   
  30.     </Grid>   
  31. </phone:PhoneApplicationPage>  
  1. using System;   
  2. using System.Collections.Generic;   
  3. using System.Linq;   
  4. using System.Net;   
  5. using System.Windows;   
  6. using System.Windows.Controls;   
  7. using System.Windows.Documents;   
  8. using System.Windows.Input;   
  9. using System.Windows.Media;   
  10. using System.Windows.Media.Animation;   
  11. using System.Windows.Shapes;   
  12. using Microsoft.Phone.Controls;   
  13. using Microsoft.Phone.Tasks;   
  14. namespace sampleApp   
  15. {   
  16.     public partial class MainPage : PhoneApplicationPage   
  17.     {   
  18.         // 構(gòu)造函數(shù)   
  19.         public MainPage()   
  20.         {   
  21.             InitializeComponent();   
  22.         }   
  23.         private void button1_Click(object sender, RoutedEventArgs e)   
  24.         {   
  25.             MediaPlayerLauncher player = new MediaPlayerLauncher();   
  26.             player.Controls = MediaPlaybackControls.All;   
  27.             player.Location = MediaLocationType.Install;   
  28.             player.Media = new Uri("分飛燕.mp3", UriKind.Relative);   
  29.             player.Orientation = MediaPlayerOrientation.Portrait;   
  30.             player.Show();   
  31.         }   
  32.     }   
  33. }   

例二:搜索任務(wù)。

SearchTask類也是一個啟動器,這個家伙更簡單了,它只有一個屬性要設(shè)置——SearchQuery,就是我們要搜索的關(guān)鍵字。

  1. <phone:PhoneApplicationPage    
  2.     x:Class="sampleApp.Page1"   
  3.     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   
  4.     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   
  5.     xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"   
  6.     xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"   
  7.     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"   
  8.     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"   
  9.     FontFamily="{StaticResource PhoneFontFamilyNormal}"   
  10.     FontSize="{StaticResource PhoneFontSizeNormal}"   
  11.     Foreground="{StaticResource PhoneForegroundBrush}"   
  12.     SupportedOrientations="Landscape" Orientation="Landscape"   
  13.     mc:Ignorable="d" d:DesignHeight="480" d:DesignWidth="728"   
  14.     shell:SystemTray.IsVisible="True">   
  15.     <!--LayoutRoot 是包含所有頁面內(nèi)容的根網(wǎng)格-->   
  16.     <Grid x:Name="LayoutRoot" Background="Transparent">   
  17.         <Grid.RowDefinitions>   
  18.             <RowDefinition Height="Auto"/>   
  19.             <RowDefinition Height="*"/>   
  20.         </Grid.RowDefinitions>   
  21.         <!--TitlePanel 包含應(yīng)用程序的名稱和頁標(biāo)題-->   
  22.         <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">   
  23.             <TextBlock x:Name="ApplicationTitle" Text="我的應(yīng)用程序" Style="{StaticResource PhoneTextNormalStyle}"/>   
  24.             <TextBlock x:Name="PageTitle" Text="搜索" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>   
  25.         </StackPanel>   
  26.         <!--ContentPanel - 在此處放置其他內(nèi)容-->   
  27.         <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">   
  28.             <TextBox Height="72" HorizontalAlignment="Left" Margin="12,86,0,0" Name="txtKey" VerticalAlignment="Top" Width="460" />   
  29.             <Button Content="搜索" Height="72" HorizontalAlignment="Left" Margin="480,86,0,0" Name="button1" VerticalAlignment="Top" Width="160" Click="button1_Click" />   
  30.         </Grid>   
  31.     </Grid>   
  32. </phone:PhoneApplicationPage> 
  1. using System;   
  2. using System.Collections.Generic;   
  3. using System.Linq;   
  4. using System.Net;   
  5. using System.Windows;   
  6. using System.Windows.Controls;   
  7. using System.Windows.Documents;   
  8. using System.Windows.Input;   
  9. using System.Windows.Media;   
  10. using System.Windows.Media.Animation;   
  11. using System.Windows.Shapes;   
  12. using Microsoft.Phone.Controls;   
  13. using Microsoft.Phone.Tasks;   
  14. namespace sampleApp   
  15. {   
  16.     public partial class Page1 : PhoneApplicationPage   
  17.     {   
  18.         public Page1()   
  19.         {   
  20.             InitializeComponent();   
  21.         }   
  22.         private void button1_Click(object sender, RoutedEventArgs e)   
  23.         {   
  24.             SearchTask searcher = new SearchTask();   
  25.             searcher.SearchQuery = txtKey.Text;   
  26.             searcher.Show();   
  27.         }   
  28.     }   
  29. }  

下一節(jié)開始,我們討論獨立存儲。

還有就是提一下建議,博客編輯器有問題,每次都這樣,***次自動保存草稿后,后面就不會保存了,編輯器內(nèi)的文本無法選定。而點擊發(fā)表時沒有反應(yīng),非得刷新頁面。

責(zé)任編輯:閆佳明 來源: oschina
相關(guān)推薦

2013-04-18 13:56:09

Windows Pho啟動器與選擇器

2013-04-18 13:47:43

Windows Pho啟動器與選擇器發(fā)送短信

2013-04-18 11:13:04

Windows Pho啟動器與選擇器BingMapsDir

2013-04-18 13:28:19

Windows Pho啟動器與選擇器

2012-06-20 10:21:50

Windows Pho

2012-06-21 10:59:31

Windows Pho

2025-03-28 02:44:00

2010-08-06 15:44:28

Windows PhoWindows PhoSilverlight

2010-04-12 17:32:59

Windows Pho

2011-10-19 09:56:58

Gnome Pie程序啟動器

2010-09-02 11:26:33

CSS選擇器偽類

2012-04-16 14:32:31

iOS選擇器代碼

2013-07-31 13:13:50

Windows PhoMVVM模式

2011-11-28 13:42:55

Sencha Touc組件選擇器

2012-12-27 14:08:39

Android開發(fā)顏色選擇器

2017-03-20 14:46:07

Android日期時間選擇器

2009-06-30 13:58:00

Java啟動器

2012-11-09 14:33:38

WindowsChrome

2012-04-19 08:42:22

春Phone沙龍

2013-04-19 17:11:02

Windows PhoWindows Pho
點贊
收藏

51CTO技術(shù)棧公眾號