• Define layouts with XAML
XAML gives you a flexible layout system that lets you use automatic sizing, layout panels, visual states, and even separate UI definitions to create a responsive UI. With a flexible design, you can make your app look great on screens with different app window sizes, resolutions, pixel densities, and orientations.
Here, we discuss how to use XAML properties and layout panels to make your app responsive and adaptive. We build on important info about responsive UI design and techniques found in Introduction to UWP app design. You should understand what effective pixels are and understand each of the responsive design techniques: Reposition, Resize, Reflow, Reveal, Replace, and Re-architect.
Note Your app layout begins with the navigation model you choose, like whether to use a Pivot with the ‘tabs and pivot’model or SplitView with the ‘nav pane’ model. For more info about that, see Navigation design basics for UWP apps. Here, we talk about techniques to make the layout of a single page or group of elements responsive. This info is applicable regardless of which navigation model you choose for your app.
The XAML framework provides several levels of optimization you can use to create a responsive UI.
• Fluid layout Use layout properties and panels to make your default UI fluid.
The foundation of a responsive layout is the appropriate use of layout properties and panels to reposition, resize, and reflow content. You can set a fixed size on an element, or use automatic sizing to let the parent layout panel size it. The various Panel classes, such as Canvas, Grid, RelativePanel and StackPanel, provide different ways to size and position their children.
• Adaptive layout Use visual states to make significant alterations to your UI based on window size or other changes.
When your app window grows or shrinks beyond a certain amount, you might want to alter layout properties to reposition, resize, reflow, reveal, or replace sections of your UI. You can define different visual states for your UI, and apply them when the window width or window height crosses a specified threshold. An AdaptiveTriggerprovides an easy way to set the threshold (also called 'breakpoint') where a state is applied.
• Tailored layout A tailored layout is optimized for a specific device family or range of screen sizes. Within the device family, the layout should still respond and adapt to changes within the range of supported window sizes.
Note With Continuum for Phones, users can connect their phones to a monitor, mouse, and keyboard. This capability blurs the lines between phone and desktop device families.
Approaches to tailoring include
o Create custom trigger
You can create a device family trigger and modify its setters, as for adaptive triggers.
o Use separate XAML files to define distinct views for each device family.
You can use separate XAML files with the same code file to define per-device family views of the UI.
o Use separate XAML and code to provide different implementations for each device family.
You can provide different implementations of a page (XAML and code), then navigate to a particular implementation based on the device family, screen size, or other factors.
•กำหนดรูปแบบที่มี XAML
XAML ช่วยให้คุณมีระบบรูปแบบที่มีความยืดหยุ่นที่ช่วยให้คุณใช้การปรับขนาดแบบอัตโนมัติ, การติดตั้งรูปแบบรัฐภาพและแม้กระทั่งคำจำกัดความ UI ที่แยกต่างหากเพื่อสร้าง UI ตอบสนอง ด้วยการออกแบบที่มีความยืดหยุ่นที่คุณสามารถทำให้แอปของคุณดูดีบนหน้าจอที่มีขนาดแตกต่างกันหน้าต่างแอปพลิเคมติความหนาแน่นพิกเซลและหมุน.
ที่นี่เราจะหารือเกี่ยวกับวิธีการใช้คุณสมบัติ XAML และแผงรูปแบบที่จะทำให้แอปของคุณตอบสนองและปรับตัว เราสร้างข้อมูลที่สำคัญเกี่ยวกับการออกแบบ UI ตอบสนองและเทคนิคที่พบในเบื้องต้นเกี่ยวกับการออกแบบแอพพลิเค UWP คุณควรจะเข้าใจในสิ่งที่พิกเซลที่มีประสิทธิภาพและทำความเข้าใจในแต่ละส่วนของเทคนิคการออกแบบที่ตอบสนอง: แก้ไขและปรับขนาด Reflow เปิดเผยแทนที่และ Re-สถาปนิก.
หมายเหตุ: รูปแบบของแอปเริ่มต้นด้วยรูปแบบการนำทางที่คุณเลือกเช่นว่าจะใช้ Pivot กับ ของแท็บและ pivot'model หรือ SplitView กับ 'บานหน้าต่างนำทาง' รุ่น สำหรับข้อมูลเพิ่มเติมเกี่ยวกับที่ดูพื้นฐานการออกแบบนำทางสำหรับแอพพลิเค UWP ที่นี่เราพูดคุยเกี่ยวกับเทคนิคที่จะทำให้รูปแบบของหน้าเดียวหรือกลุ่มขององค์ประกอบที่ตอบสนอง ข้อมูลนี้จะบังคับโดยไม่คำนึงถึงระบบนำทางรูปแบบที่คุณเลือกสำหรับ app ของคุณ.
กรอบ XAML ให้หลายระดับของการเพิ่มประสิทธิภาพที่คุณสามารถใช้เพื่อสร้าง UI ที่ตอบสนอง.
•ของไหลรูปแบบการใช้งานคุณสมบัติรูปแบบและการติดตั้งที่จะทำให้ของเหลว UI เริ่มต้นของคุณ.
รากฐานของ รูปแบบที่ตอบสนองการใช้งานที่เหมาะสมของรูปแบบและคุณสมบัติของแผงเซลล์เพื่อเปลี่ยนตำแหน่ง, ปรับขนาดและเนื้อหา reflow คุณสามารถตั้งค่าขนาดคงที่ในองค์ประกอบหรือใช้การปรับขนาดโดยอัตโนมัติเพื่อให้ผู้ปกครองขนาดแผงรูปแบบมัน เรียนแผงต่างๆเช่นผ้าใบ, ตาราง, RelativePanel และ StackPanel ให้วิธีการที่แตกต่างกันขนาดและตำแหน่งของเด็กของพวกเขา.
•รูปแบบการปรับตัวใช้รัฐภาพเพื่อให้การเปลี่ยนแปลงที่สำคัญในการ UI ของคุณขึ้นอยู่กับขนาดของหน้าต่างหรือการเปลี่ยนแปลงอื่น ๆ .
เมื่อหน้าต่างแอปของคุณ เติบโตหรือหดเกินจำนวนหนึ่งคุณอาจต้องการที่จะปรับเปลี่ยนรูปแบบคุณสมบัติเพื่อเปลี่ยนตำแหน่ง, ปรับขนาด, reflow เปิดเผยหรือเปลี่ยนในส่วนของคุณ UI คุณสามารถกำหนดสหรัฐอเมริกาภาพที่แตกต่างกันสำหรับคุณ UI และใช้พวกเขาเมื่อความกว้างหรือความสูงหน้าต่างหน้าต่างข้ามเกณฑ์ที่ระบุ AdaptiveTriggerprovides วิธีง่ายๆในการกำหนดเกณฑ์ (ที่เรียกว่า 'เบรกพอยต์') ซึ่งเป็นรัฐที่ถูกนำไปใช้.
•รูปแบบเทเลอร์รูปแบบที่ปรับแต่งเป็นที่เหมาะสำหรับครอบครัวอุปกรณ์เฉพาะหรือช่วงที่มีขนาดหน้าจอ ภายในครอบครัวอุปกรณ์รูปแบบยังคงควรจะตอบสนองและปรับตัวเข้ากับการเปลี่ยนแปลงภายในช่วงของขนาดหน้าต่างสนับสนุน.
หมายเหตุด้วยต่อเนื่องสำหรับโทรศัพท์มือถือที่ผู้ใช้สามารถเชื่อมต่อโทรศัพท์ของพวกเขาในการตรวจสอบเมาส์คีย์บอร์ดและ ความสามารถนี้พร่าเลือนเส้นระหว่างโทรศัพท์และเดสก์ท็ครอบครัวอุปกรณ์.
แนวทางการตัดเย็บรวมถึง
o สร้างที่กำหนดเองเรียก
คุณสามารถสร้างทริกเกอร์ครอบครัวอุปกรณ์และปรับเปลี่ยน setters ของตนในฐานะที่เป็นทริกเกอร์การปรับตัว.
o ใช้แฟ้ม XAML ที่แยกต่างหากเพื่อกำหนดมุมมองที่แตกต่างกันสำหรับแต่ละครอบครัวอุปกรณ์ .
คุณสามารถใช้แฟ้ม XAML แยกต่างหากจากไฟล์รหัสเดียวกันที่จะกำหนดต่ออุปกรณ์มุมมองครอบครัวของ UI.
o ใช้ XAML แยกต่างหากและรหัสเพื่อให้การใช้งานที่แตกต่างกันสำหรับแต่ละครอบครัวอุปกรณ์.
คุณสามารถให้การใช้งานที่แตกต่างกันของหน้าเว็บ (XAML และรหัส ) จากนั้นไปที่การดำเนินงานโดยเฉพาะอย่างยิ่งบนพื้นฐานของครอบครัวอุปกรณ์ขนาดหน้าจอหรือปัจจัยอื่น ๆ
การแปล กรุณารอสักครู่..
