Layout properties and panels
Layout is the process of sizing and positioning objects in your UI. To position visual objects, you must put them in a panel or other container object. The XAML framework provides various panel classes, such as Canvas, Grid,RelativePanel and StackPanel, which serve as containers and enable you to position and arrange the UI elements within them.
The XAML layout system supports both static and fluid layouts. In a static layout, you give controls explicit pixel sizes and positions. When the user changes the resolution or orientation of their device, the UI doesn't change. Static layouts can become clipped across different form factors and display sizes.
Fluid layouts shrink, grow, and reflow to respond to the visual space available on a device. To create a fluid layout, use automatic or proportional sizing for elements, alignment, margins, and padding, and let layout panels position their children as needed. You arrange child elements by specifying how they should be arranged in relationship to each other, and how they should be sized relative to their content and/or their parent.
In practice, you use a combination of static and fluid elements to create your UI. You still use static elements and values in some places, but make sure that the overall UI is responsive and adapts to different resolutions, layouts, and views.
Layout properties
To control the size and position of an element, you set its layout properties. Here are some common layout properties and their effect.
Height and Width
Set the Height and Width properties to specify the size of an element. You can use fixed values measured in effective pixels, or you can use auto or proportional sizing. To get the size of an element at runtime, use the ActualHeight andActualWidth properties instead of Height and Width.
You use auto sizing to let UI elements resize to fit their content or parent container. You can also use auto sizing with the rows and columns of a grid. To use auto sizing, set the Height and/or Width of UI elements to Auto.
Note Whether an element resizes to its content or its container depends on the value of its HorizontalAlignment andVerticalAlignment properties, and how the parent container handles sizing of its children. For more info, see [Alignment]() and [Layout panels]() later in this article.
You use proportional sizing, also called star sizing, to distribute available space among the rows and columns of a grid by weighted proportions. In XAML, star values are expressed as * (or n* for weighted star sizing). For example, to specify that one column is 5 times wider than the second column in a 2-column layout, use "5*" and "*" for the Widthproperties in the ColumnDefinition elements.
This example combines fixed, auto, and proportional sizing in a Grid with 4 columns.
คุณสมบัติเค้าโครงและแผงรูปแบบคือกระบวนการของการปรับขนาดและการวางตำแหน่งวัตถุใน UI ของคุณ ตำแหน่งวัตถุภาพ , คุณจะต้องใส่ในภาชนะหรือวัตถุที่แผงอื่น ๆ และ XAML กรอบให้ชั้นเรียนแผงต่างๆ เช่น ผ้าใบ , ตาราง , และ relativepanel Stackpanel ซึ่งใช้เป็นภาชนะและช่วยให้คุณตำแหน่งและการจัดองค์ประกอบ UI ภายในพวกเขาระบบผัง XAML รองรับทั้งแบบคงที่และของเหลวเค้าโครง ในรูปแบบคงที่ คุณให้การควบคุมขนาดพิกเซล อย่างชัดเจน และตำแหน่ง เมื่อผู้ใช้มีการเปลี่ยนแปลงแก้ไขหรือวางแนวของอุปกรณ์ของพวกเขา , UI ไม่ได้เปลี่ยน รูปแบบคงที่จะกลายเป็นตัดข้ามปัจจัยรูปแบบที่แตกต่างกันและจอแสดงผลขนาดรูปแบบของเหลวหดเติบโตและ reflow ตอบสนองพื้นที่ภาพที่มีอยู่ในอุปกรณ์ เพื่อสร้างรูปแบบของเหลวที่ใช้อัตโนมัติขนาดหรือสัดส่วนองค์ประกอบแนวระยะขอบและช่องว่างภายในและปล่อยให้แผงผังตำแหน่งของลูกได้ตามต้องการ คุณจัดองค์ประกอบเด็กโดยระบุว่าพวกเขาควรจะจัดในความสัมพันธ์กับแต่ละอื่น ๆและวิธีการที่พวกเขาควรจะมีขนาดสัมพันธ์กับเนื้อหาของพวกเขาและ / หรือผู้ปกครองของพวกเขาในการปฏิบัติ คุณใช้การรวมกันขององค์ประกอบคงที่และของเหลวที่จะสร้าง UI ของคุณ คุณยังคงใช้องค์ประกอบคงที่และค่าในบางสถานที่ แต่ให้แน่ใจว่า UI โดยรวมคือการตอบสนองและปรับความละเอียดที่แตกต่างกัน มุมมอง เค้าโครงและคุณสมบัติเค้าโครงการควบคุมขนาดและตำแหน่งขององค์ประกอบที่คุณตั้งค่ารูปแบบของมัน คุณสมบัติ นี่คือบางส่วนคุณสมบัติรูปแบบทั่วไปและผลกระทบของพวกเขาความสูงและความกว้างกำหนดความสูงและความกว้างของการระบุขนาดขององค์ประกอบ คุณสามารถใช้แก้ไขค่าวัดในพิกเซล , หรือคุณสามารถใช้ Auto หรือสัดส่วนขนาด เพื่อให้ได้ขนาดขององค์ประกอบที่ runtime ใช้ actualheight andactualwidth คุณสมบัติแทนความสูงและความกว้างที่คุณใช้โดยอัตโนมัติปรับขนาดเพื่อให้องค์ประกอบ UI ปรับขนาดให้พอดีกับเนื้อหา หรือภาชนะที่พ่อแม่ของพวกเขา นอกจากนี้คุณยังสามารถใช้รถยนต์ขนาดกับแถวและคอลัมน์ของตาราง ใช้ Auto ขนาด กำหนดความสูงและ / หรือความกว้างขององค์ประกอบ UI ให้โดยอัตโนมัติทราบว่าองค์ประกอบของเนื้อหาหรือปรับขนาดของภาชนะขึ้นอยู่กับมูลค่าของ horizontalalignment andverticalalignment คุณสมบัติและวิธีการจัดการภาชนะขนาดพ่อแม่ของเด็กของ สำหรับข้อมูลเพิ่มเติมดู [ แนว ] ( ) [ ] ( ) และแผงผังในภายหลังในบทความนี้คุณใช้สัดส่วนขนาด เรียกว่าดาวขนาด การกระจายพื้นที่ว่างระหว่างแถวและคอลัมน์ของตาราง โดยสัดส่วนน้ำหนัก . ใน XAML , ดาวค่าแสดงเป็น * * * * ( หรือ N * ดาวขนาดหนัก ) ตัวอย่างเช่น การระบุว่าคอลัมน์หนึ่งครั้งที่ 5 กว้างกว่าคอลัมน์ที่สองใน 2 คอลัมน์ การใช้ " * 5 " และ " * " สำหรับ widthproperties ใน columndefinition องค์ประกอบตัวอย่างนี้รวมซ่อม รถยนต์ ขนาด และสัดส่วนในตารางมี 4 คอลัมน์
การแปล กรุณารอสักครู่..
