Windows Phone Development (10): Common Controls (top)

Source: Internet
Author: User

Windows phone controls have several sources, like traditional desktop application development or Web development, with controls that are provided by default and those published by third-party developers. In general, if the interface layout is not overly complex, it is sufficient to use the default controls. In contrast, although many visual controls are available in the Android SDK, you will find that there are not many real-world developments, and that many of the controls are simply furnishings, without exposing the appropriate operating methods or more listeners that can be used by developers themselves (I'm used to translating listeners here, In Android there is no use of events like C #, but a new listener, and of course the principle is similar.

In addition to the game, we basically use Silverlight on WP, so most of WP's controls are from Silverlight (silver).

One, TextBlock controls.


The function of this control and Android inside the same textview, no it is used to display some static text, of course, this static text is not that we can not modify, but just a relative word, relative to the text box control can let the user input, nothing, If you have done WinForm development, it is equivalent to the Label control, if you have been exposed to the previous VC in the development of MFC, but also similar to the static text control. Well, that's a lot of crap, let's take a look at the example.

    1. <textblock x:name= "Txtblock" text= "hello. "/>


Yes, so we declare a TextBlock on the page and set the text shown above to "hello".
I won't say much about how to declare a control, you can drag and drop it directly from the Toolbox using Design view, and then set it in the Properties window, similar to the traditional WinForm development.

For TextBlock controls, perhaps we have two of the most commonly used properties:
1, text, no more introduction, of course, the text content is displayed.
2, FontSize, adjust the size of the font.

Let me go through an example of the advanced use of the TextBlock control, what is advanced? Ha, you'll know when you see it.

    1. <textblock x:name= "Txtblock" fontsize= "textwrapping=" "Wrap" >
    2. Hello,<bold> Xiao Huang </Bold>,<Italic> what time do you get up today? </Italic>
    3. </TextBlock>


(Fig. 1)

In the example above, we see that "hello" is the normal display, "small yellow" is bold, "what time to get up today" is italic body. That is, within the TextBlock we can use the relevant document formatting tags, so that the text can be more
Forms of display.

Let's look at an example.

    1. <textblock grid.row= "2" fontsize= ">"
    2. Youku Video <LineBreak/> Potato Videos
    3. </TextBlock>


This way, we can wrap the text in a line.
(Fig. 2)

Let's look at the use of the run element below, because it inherits from Silverlight, so not all tags are valid, so we might as well try.

    1. <textblock grid.row= "4" fontsize= "+" textwrapping= "Wrap" >
    2. <run fontstyle= "Italic"
    3. Fontfamily= "Tahoma"
    4. Fontsize= "65"
    5. foreground= "Orange" >
    6. Lotus Pond Moonlight
    7. </Run>
    8. </TextBlock>


(Fig. 3)


Second, the button control.


This guy believes that I do not have to introduce, we are most familiar with, the button in the development of the use of the frequency is gray often high, and it is often simple to use gray, the key is to handle its click event, it is basically finished.

    1. <button content= "click Me" horizontalalignment= "left" margin= "58,68,0,0" Name= "button1" verticalalignment= "Top"
    2. click= "Button1_Click"/>


If you're not very familiar with WPF or Silverlight, here's a quick word,

(Fig. 4)

From what we see, the button is derived from ContentControl, that is, if you want to set the text displayed on the button, you should set its content property.
Note that the content property is of type object, that is, we can not only set the text as the content of the button, as long as it can be displayed, we can assign to the content property, do not believe? Give it a try.

  1. <button horizontalalignment= "left" margin= "58,68,0,0" Name= "button1" verticalalignment= "Top"
  2. click= "Button1_Click" >
  3. <Button.Content>
  4. <ellipse height= "Width=" >
  5. <Ellipse.Fill>
  6. <lineargradientbrush
  7. Startpoint= "0,0"
  8. Endpoint= ">"
  9. <gradientstop color= "Yellow" offset= "0.12"/>
  10. <gradientstop color= "mediumvioletred" offset= "1"/>
  11. </LinearGradientBrush>
  12. </Ellipse.Fill>
  13. </Ellipse>
  14. </Button.Content>
  15. </Button>


Is it interesting to see after running?
(Fig. 5)

Third, CheckBox control.


Let alone this stuff, see the example.

    1. <stackpanel orientation= "Vertical" >
    2. <checkbox content= "cabbage" ischecked= "True"/>
    3. <checkbox content= "Pear"/>
    4. <checkbox content= "Apple" ischecked= "False"/>
    5. <checkbox content= "Flowers"/>
    6. </StackPanel>


(Fig. 6)

Windows Phone Development (10): Common Controls (top)

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.