Windows Phone之彈出對話方塊組件嘗試Demo

來源:互聯網
上載者:User

廢話不多說,在公司等我家妞兒下班順便研究測試了一下一個對話方塊的組件,覺得挺不錯的,推薦一下Windows phone的開發人員。

首先下載一個第三方的組件,放在bin目錄裡面。:點擊開啟連結

其次我直接貼代碼

接下來是前台的XAML代碼:

<phone:PhoneApplicationPage     x:Class="MicroBlogForWP7.AccountManager"    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"    FontFamily="{StaticResource PhoneFontFamilyNormal}"    FontSize="{StaticResource PhoneFontSizeNormal}"    Foreground="{StaticResource PhoneForegroundBrush}"    SupportedOrientations="Portrait" Orientation="Portrait"    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"    shell:SystemTray.IsVisible="True"    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit">     <!--LayoutRoot is the root grid where all page content is placed-->    <Grid x:Name="LayoutRoot" >        <Grid.Background>            <ImageBrush ImageSource="/Resource/Image/BS480480.png"></ImageBrush>        </Grid.Background>        <Grid.RowDefinitions>            <RowDefinition Height="Auto"/>            <RowDefinition Height="*"/>        </Grid.RowDefinitions>        <!--TitlePanel contains the name of the application and page title-->        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">            <TextBlock x:Name="ApplicationTitle" Text="Test" Foreground="DarkRed"/>            <TextBlock x:Name="PageTitle" Text="測試頁" Margin="9,-7,0,0"  Foreground="DarkRed" FontSize="55"/>        </StackPanel>        <!--ContentPanel - place additional content here-->        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">                         <Button Content="提示1" Foreground="DarkRed" Height="72" HorizontalAlignment="Left" Margin="47,33,0,0" Name="button1" VerticalAlignment="Top" Width="160" Click="button1_Click" />            <Button Content="提示2" Foreground="DarkRed" Height="72" HorizontalAlignment="Left" Margin="47,123,0,0" Name="button2" VerticalAlignment="Top" Width="160" Click="button2_Click" />            <Button Content="提示並輸入密碼" Foreground="DarkRed"  Height="72" HorizontalAlignment="Left" Margin="47,216,0,0" Name="button3" VerticalAlignment="Top" Width="263" Click="button3_Click" />            <Button Content="提示並輸入帳號" Height="72"  Foreground="DarkRed" HorizontalAlignment="Left" Margin="47,313,0,0" Name="button4" VerticalAlignment="Top" Width="263" Click="button4_Click" />            <Button Content="提示3"  Foreground="DarkRed"  Height="72" HorizontalAlignment="Left" Margin="76,414,0,0" Name="button5" VerticalAlignment="Top" Width="131" Click="button5_Click" />        </Grid>    </Grid> </phone:PhoneApplicationPage>

最後是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.Shapes;using Microsoft.Phone.Controls;using System.IO.IsolatedStorage;using Coding4Fun.Phone;using Coding4Fun.Phone.Controls;namespace MicroBlogForWP7{    public partial class AccountManager : PhoneApplicationPage    {        public AccountManager()        {            InitializeComponent();        }        private void button1_Click(object sender, RoutedEventArgs e)        {            var messagePrompt = new MessagePrompt            {                Title = "提示",                Message = "錯誤的資訊提示",            };            messagePrompt.Show();        }        private void button2_Click(object sender, RoutedEventArgs e)        {            var about = new AboutPrompt();            about.Completed += baseObject_Completed;            about.Show();        }        void baseObject_Completed(object sender, PopUpEventArgs<object, PopUpResult> e)        {            if (e.PopUpResult == PopUpResult.Ok)                MessageBox.Show("OK!");            else if (e.PopUpResult == PopUpResult.Cancelled)                MessageBox.Show("CANCELLED!");            else                MessageBox.Show("meh?");        }        private void button3_Click(object sender, RoutedEventArgs e)        {            var passwordInput = new PasswordInputPrompt            {                Title = "Basic Input",                Message = "I'm a basic input prompt",            };            passwordInput.Completed += input_Completed;            passwordInput.Show();        }        void input_Completed(object sender, PopUpEventArgs<string, PopUpResult> e)        {            if (e.PopUpResult == PopUpResult.Ok)                MessageBox.Show("You typed: " + e.Result);            else if (e.PopUpResult == PopUpResult.Cancelled)                MessageBox.Show("CANCELLED! " + e.Result);            else                MessageBox.Show("meh?  " + e.Result);        }        private void button4_Click(object sender, RoutedEventArgs e)        {            var input = new InputPrompt            {                Title = "Basic Input",                Message = "I'm a basic input prompt",            };            input.Completed += input_Completeds;            input.Show();        }        void input_Completeds(object sender, PopUpEventArgs<string, PopUpResult> e)        {            if (e.PopUpResult == PopUpResult.Ok)                MessageBox.Show("You typed: " + e.Result);            else if (e.PopUpResult == PopUpResult.Cancelled)                MessageBox.Show("CANCELLED! " + e.Result);            else                MessageBox.Show("meh?  " + e.Result);        }        private void button5_Click(object sender, RoutedEventArgs e)        {            var messagePrompt = new MessagePrompt            {                Title = "Basic Message",                Message = "I'm a basic message prompt.  ",            };            messagePrompt.Completed += stringObject_Completed;            messagePrompt.Show();        }        void stringObject_Completed(object sender, PopUpEventArgs<string, PopUpResult> e)        {            if (e.PopUpResult == PopUpResult.Ok)                MessageBox.Show("OK: " + e.Result);            else if (e.PopUpResult == PopUpResult.Cancelled)                MessageBox.Show("CANCELLED: " + e.Result);            else                MessageBox.Show("meh?: " + e.Result);        }    }}

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.