另類彈窗,coding4Fun外掛程式提供的彈窗

來源:互聯網
上載者:User

從我的網易部落格移過來的。。

 

先提供吧。
 

 

 

 這個是coding4Fun提供的MessagePrompt彈窗。還提供了ToastPrompt:土司彈出框,類似於土司推播通知。

AboutPrompt:說明彈出框,特點是彈出框會在螢幕中間,其他的彈出框是在螢幕的上方(其他可以通過Margin調整文位置)。

PasswordInputPrompt:密碼輸入彈出框。

InputPrompt:輸入彈出框,用於彈出輸入框輸入其他的資訊。

這些都不討論了。需要的可以到官網文檔:http://coding4fun.codeplex.com/wikipage?title=MessagePrompt&referringTitle=Documentation

或者到:http://coding4fun.codeplex.com/wikipage?title=MessagePrompt&referringTitle=Documentation瞭解。

今天討論用MessagePrompt自訂自己的彈窗。彈窗可以帶輸入框等內容。

先建立一個window phone User Control。命名為BodyUserControl。這個主要是設計彈窗的內容。

添加代碼:

 

       

 <Border BorderBrush="YellowGreen" BorderThickness="2">            <StackPanel x:Name="LayoutRoot1" Background="{StaticResource PhoneChromeBrush}"  Margin="0,0,0,10">                <TextBlock Text="Body declared in UserControl XAML" HorizontalAlignment="Center"/>                <Image Source="/RoundBtnDemo;component/images/MB_0010_radio.png" Height="80" Width="80" HorizontalAlignment="Center"/>                <TextBox x:Name="msg" />                <Border Background="YellowGreen" Height="100" Width="400">                    <TextBlock x:Name="tx" Text="This is the first text in the Body section. Another Body content here" TextWrapping="Wrap" VerticalAlignment="Center"/>                </Border>            </StackPanel>        </Border>

 



為:

在主介面裡面的需要彈窗的onclick事件或者其他裡面添加代碼:

 

 MessagePrompt msgPrompt = new MessagePrompt();            msgPrompt.Title = "UserControl test";            msgPrompt.Body = new BodyUserControl();            msgPrompt.IsAppBarVisible = false;            msgPrompt.Completed += new EventHandler<PopUpEventArgs<string, PopUpResult>>(msgPrompt_Completed);            msgPrompt.Show();

 


 最重要的來了:怎麼擷取彈窗上的TextBox 的內容呢?

其實是在那個Completed事件可以擷取:

 

 

 void msgPrompt_Completed(object sender, PopUpEventArgs<string, PopUpResult> e)        {            if (e.PopUpResult == PopUpResult.Ok)//先判斷是否是點擊那個勾,也就是確定            {                var msgPrompt = sender as MessagePrompt;//把sender轉為MessagePrompt對象                var bodyControl = msgPrompt.Body as BodyUserControl;//取出BodyUserControl對象  //取出BodyUserControl中Name為msg,也就是那個TextBox。  //這裡的Showmsg是一個TextBlock,這樣,就能取到彈窗上的控制項的值                ShowMsg.Text = bodyControl.msg.Text;            }                    }

 


 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.