Silverlight入门学习(28)

Silverlight入门学习(28),第1张

概述原文地址: http://www.dingos.cn/index.php?topic=2000.0 第二十八章   如何在 Silverlight 页面上d出层? 在 xaml 页面上添加一个按钮,如下所示: < Grid x : Name ="LayoutRoot" Background ="White" >     < Button Width ="100" Height ="50" x :

原文地址: http://www.dingos.cn/index.php?topic=2000.0

第二十八章   如何在 Silverlight 页面上d出层?

xaml 页面上添加一个按钮,如下所示:

< GrID x : name ="LayoutRoot" Background ="White" >

    < button WIDth ="100" Height ="50" x : name ="showPopup" Click ="showPopup_Click"

         Content ="Show Popup" />

</ GrID >

在后置代码文件( page.xaml.cs )中添加如下代 码

Popup p = new Popup ();

private voID showPopup_Click(object sender,RoutedEventArgs e) {

    // Create a panel control to host other controls

    StackPanel panel1 = new StackPanel ();

    panel1.Background = new SolIDcolorBrush (colors .Gray);

 

    // Create a button

    button button1 = new button ();

    button1.Content = "Close" ;

    button1.margin = new Thickness (5.0);

    button1.Click += new RoutedEventHandler (button1_Click);

 

    // Create a text label

    TextBlock textblock1 = new TextBlock ();

    textblock1.Text = "The popup control" ;

    textblock1.margin = new Thickness (5.0);

 

    // Add text label and button to the panel

    panel1.Children.Add(textblock1);

    panel1.Children.Add(button1);

 

    // Now,make the panel a child of the popup so that

    // the panel will be shown within the Popup when displayed.

    p.Child = panel1;

 

    // Set the position.

    p.VerticalOffset = 25;

    p.HorizontalOffset = 25;

 

    // Show the popup.

    p.IsOpen = true ;

}

 

voID button1_Click(object sender,RoutedEventArgs e) {

    // Close the popup.

    p.IsOpen = false ;

}

注意:需要添加 System.windows.Controls.Primitives 命名控件的引用。

运行应用程序。可以看见页面上有一个按钮。当点击按钮时,一个具有文本标签和按钮的d出层会显 示。当点击d出层中按钮,将会关闭d出层。

总结

以上是内存溢出为你收集整理的Silverlight入门学习(28)全部内容,希望文章能够帮你解决Silverlight入门学习(28)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1034014.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-24
下一篇2022-05-24

发表评论

登录后才能评论

评论列表(0条)

    保存