Windows Phone Development Learning Note (1)---------Custom Bullet Box

Source: Internet
Author: User

Windows Phone Development Learning Note (1)

---------A custom Bullet box

Customizing a bullet box in WP can be accomplished through the popup class.

The syntax of the popup is:

[Contentpropertyattribute ("Child")]

[Localizabilityattribute (Localizationcategory.none)]

            public class popup:frameworkelement, IAddChild;

     This is a small use of the popup

            Popup codepopup = new popup ();

TextBlock popuptext = new TextBlock ();

Popuptext.text = "Popup Text";

              Popuptext.background = Brushes.lightblue;popuptext.foreground = Brushes.blue;

Codepopup.child = Popuptext;

Of course, it's all copied from MSDN, so let's use it for a moment:

Create a new Window phone project, name casually, create a new class for the box, named Mymessagebox; add member variable on it, private popup popup;

Create a new control layout file, named message, for the layout of the frame;

Add the control you want in the message;

What I've added here is: 

<usercontrol x:class="Appstudy_1.message"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="Http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"XMLNS:MC="http://schemas.openxmlformats.org/markup-compatibility/2006"mc:ignorable="D"FontFamily="{StaticResource Phonefontfamilynormal}"FontSize="{StaticResource Phonefontsizenormal}"Foreground="{StaticResource Phoneforegroundbrush}"D:designheight="480"D:designwidth="480"> <grid x:name="LayoutRoot"Background="{StaticResource Phonechromebrush}"> <textblock text="Li Gui Hair"Fontsize=" -"/> <button content="OK"/> </Grid></UserControl>
View Code

Then we can add the displayed code in the Mymessagebox, and add the method Show () in Mymessagebox to show the Bullet box

First we need to get the popup new out, namely: Popup=new popup ();

Then new a StackPanel object is used to hold the frame interface,

Add a message to StackPanel,

Create a template for StackPanel,

The Popup object's byte point is then set to StackPanel,

Display the Popup

The code is: 

 Public voidShow () {Popup=NewPopup (); StackPanel Panel=NewStackPanel (); Panel. Children.add (Newappstudy_1.message ()); Panel. Children.add (NewRectangle {Width =480, Height = -, Fill =NewSolidColorBrush (colors.gray), Opacity =0.5 }); Popup. Child=Panel; Popup. IsOpen=true; }
View Code

Add a button in the main window and set the click function to execute the Show method;

This is where you can display the window.

    

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.