Win10 UWP Intro to controls and events

Source: Internet
Author: User

This translation, if there is no wrong can be sent mailbox

To create a page, you can display the data through a button, a textbox input, a combo box, and get user input. There are three key steps you can use to add a control:

    • Add a control to the interface

    • Set control properties, height, width, color

    • Adding events for a control

Adding controls

You can add controls in any of the following ways

    • Using the interface to drag the control directly, blend directly in the toolbox to drag the control to the interface

      Click button to drag the button interface

    • Editing in XAML<Button Content="确定"></Button>

    • Code Add control

In Visual Studio, you can use the Toolbox, XAML editor, designer, Properties window

    • Toolbox
    • XAML Editor
    • Designer
    • Properties window

The toolbox shows a lot of controls that you can use in software, you can drag controls to the interface, you can double-click controls, and the controls are automatically added to the software.

Double-click TextBox

<TextBox x:Name="textBox" TextWrapping="Wrap"Text="TextBox"/>
naming controls

In order to change the control in code, you can give the control name, x:Name write the control name, control name cannot be repeated, cannot start with a number

You can use properties to name controls

Click the control, and in the properties you can see

Name of the control to write on

Setting control Properties

You can select a control property in a property

You can edit XAML write controls

If you set the one you don't, you can reset the property

Click Re-set

You can use the following color table to set the color

Write Visual Studio in XAML when you press a key, you are prompted

Control events

Each control has a number of events, you can use XAML, property creation events, and the method of creating events is event handling, see: https://msdn.microsoft.com/windows/uwp/xaml-platform/ Events-and-routed-events-overview
Create events can be in the properties

Select event, write name, press ENTER, go to CS, event handling the first parameter is sender, reference object, second is event data
We create a click

        privatevoidButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)        {            as Button;//sender 发送者        }

If a button name is given, the code can be

Original: Https://msdn.microsoft.com/windows/uwp/controls-and-patterns/controls-and-events-intro

Win10 UWP Intro to controls and events

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.