- Библиотека пользовательского интерфейса Windows 2.x Windows UI Library 2.x
- Возможности Features
- Примеры Examples
- Документация Documentation
- Установка и использование библиотеки пользовательского интерфейса Windows Install and use the Windows UI Library
- План разработки и открытый код Open source and developer roadmap
- Список пакетов NuGet NuGet package list
- Following User Interface Guidelines
- What Are UI Guidelines?
- Do Not Rely on Guidelines Exclusively
- Начало работы с библиотекой пользовательского интерфейса Windows 2.x Getting started with the Windows UI 2.x Library
- Загрузка и установка библиотеки пользовательского интерфейса Windows Download and install the Windows UI Library
- Дополнительные шаги для проекта C++/WinRT Additional steps for a C++/WinRT project
- Дополнение к библиотеке пользовательского интерфейса Windows Contributing to the Windows UI Library
- Другие ресурсы Other resources
Библиотека пользовательского интерфейса Windows 2.x Windows UI Library 2.x
В библиотеке пользовательского интерфейса Windows предоставляются официальный набор элементов управления пользовательского интерфейса Windows и других элементов пользовательского интерфейса для приложений Windows. The Windows UI Library provides official native Windows UI controls and other user interface elements for Windows apps.
Она поддерживает совместимость низкого уровня с предыдущими версиями Windows 10, поэтому ваше приложение будет работать, даже если пользователи применяют не самую последнюю версию ОС. It maintains down-level compatibility with earlier versions of Windows 10, so your app works even if users don’t have the latest OS.
Ознакомьтесь с предварительной версией 4 библиотеки пользовательского интерфейса Windows 3 (февраль 2021 г.), крупным обновлением, связанным с платформой пользовательского интерфейса Windows 10. Check out the Windows UI Library 3 Preview 4 (February 2021), a major update to the Windows 10 UI platform.
Возможности Features
Новые элементы управления. Библиотека пользовательского интерфейса Windows содержит новые элементы управления, которые не предоставляются на платформе Windows по умолчанию. New controls: The Windows UI Library contains new controls that aren’t shipped as part of the default Windows platform.
Обновленные версии существующих элементов управления. Библиотека также содержит обновленные версии существующих элементов управления платформы Windows, которые можно использовать в более ранних версиях Windows 10. Updated versions of existing controls: The library also contains updated versions of existing Windows platform controls that you can use with earlier versions of Windows 10.
Поддержка более ранних версий Windows 10. API библиотеки пользовательского интерфейса Windows работают в предыдущих версиях Windows 10, поэтому для обеспечения работы пользователей, не использующих последние версии ОС, не нужно добавлять проверки версии или условный код XAML. Support for earlier versions of Windows 10: Windows UI Library APIs work on earlier versions of Windows 10, so you don’t have to include version checks or conditional XAML to support users who might not be running the very latest OS.
Поддержка XamlDirect. Интерфейсы API XAML Direct, предназначенные для разработчиков ПО промежуточного слоя, предоставляют доступ к функциям XAML более низкого уровня, которые обеспечивает более высокую производительность по нагрузке на ЦП и рабочему набору. Support for XamlDirect: The Xaml Direct APIs, designed for middleware developers, gives you access to a lower-level Xaml features which provide better CPU and working set performance. XamlDirect позволяет применять API XamlDirect в более ранних версиях Windows 10, не требуя писать специальный код для работы с несколькими целевыми версиями Windows 10. XamlDirect enables you to use XamlDirect APIs on earlier versions of Windows 10 without needing to write special code to handle multiple target Windows 10 versions.
Примеры Examples
Пример приложения XAML Controls Gallery включает интерактивные демонстрации и примеры кода для работы с элементами управления WinUI. The Xaml Controls Gallery sample app includes interactive demos and sample code for using WinUI controls.
Установите приложение XAML Controls Gallery из Microsoft Store. Install the XAML Controls Gallery app from the Microsoft Store
Также на сайте GitHub доступен открытый код приложения Xaml Controls Gallery. The Xaml Controls Gallery is also open source on GitHub
Документация Documentation
Практические руководства по элементам управления из библиотеки пользовательского интерфейса Windows вы найдете в документации по элементам управления универсальной платформы Windows. How-to articles for Windows UI Library controls are included with the Universal Windows Platform controls documentation.
Справочная документация по API доступна по этой ссылке: API библиотеки пользовательского интерфейса Windows. API reference docs are located here: Windows UI Library APIs.
Установка и использование библиотеки пользовательского интерфейса Windows Install and use the Windows UI Library
План разработки и открытый код Open source and developer roadmap
WinUI — проект с открытым кодом, размещенный на сайте GitHub. WinUI is an open source project hosted on GitHub. Мы рады любым сообщениям об ошибках, запросам на добавление функций и вкладам сообщества в создание кода, вносимым в репозиторий библиотеки пользовательского интерфейса Windows. We welcome bug reports, feature requests and community code contributions in the Windows UI Library repo.
Мы продолжаем разрабатывать и развивать WinUI, чтобы поддерживать новые сценарии разработки. We are continuing to develop and evolve WinUI to support more developer scenarios. Последние сведения о планах по разработке Windows см. в этой статье о стратегии развития, размещенной в репозитории библиотеки пользовательского интерфейса Windows. For the latest details about our plans for WinUI, see our roadmap on the Windows UI Library repo.
Список пакетов NuGet NuGet package list
Библиотека пользовательского интерфейса Windows содержит несколько пакетов NuGet: Список пакетов NuGet для библиотеки пользовательского интерфейса Windows. The Windows UI Library contains multiple NuGet packages: Windows UI Library NuGet package list.
Following User Interface Guidelines
This topic defines what user interface guidelines are and describes why following guidelines exclusively might not be the best strategy.
What Are UI Guidelines?
UI guidelines are collections of recommendations that designers and developers follow when creating the user interface for applications. Guidelines can include:
General design principles derived through research.
These principles can include the expression of a fundamental design philosophy, assumptions about human behavior, a design methodology, and concepts embodied in the interface.
Most, if not all, major software platforms have published guidelines for user interface design. One example is the Microsoft Windows User Experience, which is subtitled the Official Guidelines for User Interface Developers and Designers.
Local rules or style guide.
Many individual companies and organizations have their own set of documented UI rules or styles for interface design that developers in that company use. This is common in large companies especially, where a suite of applications is created internally.
Do Not Rely on Guidelines Exclusively
As an application designer, following UI guidelines helps ensure that the product allows users to apply skills they’ve already learned to common tasks and learn new tasks more easily. However, you cannot rely solely on guidelines to ensure the usability of your product. UI guidelines are often too general. Yet it’s that very generality that makes them difficult to apply. When you are trying to make specific decisions within the context of your product, a general set of guidelines might not give you enough information for you to make a decision. An example is when you’re trying to decide between method A and method B of presenting information in a dialog box.
On the other hand, guidelines can be too specific. For example, a guideline might specify having no more than seven items on a menu. However, adding additional menus might be more confusing to users than having more than seven choices on any one menu. Additionally, guidelines may conflict with one another. For example, one guideline might specify having no more than seven items on a menu, and another might specify keeping similar items grouped together on menus. Which guideline takes precedence?
Nevertheless, when designing an application, the visual consistency encouraged by UI guidelines can be helpful. Consider the consistency you find in Microsoft Word and Microsoft Excel. The user interfaces in these software products are very similar in the basic elements such as menus, toolbars, and placement of buttons in dialog boxes (that is, the surface-level interface). In addition, they are consistent in how they handle many common tasks: formatting text, saving files, and so on. Consistency in these and other elements can make it easier for users to transfer skills when learning different applications. Specific UI guidelines can help maintain consistency across different products.
This all boils down to context: A user interface needs to be designed for specific users, goals, and tasks. Guidelines may be a reasonable starting point, but they are only a starting point. The value in UI consistency lies in effective learning, by making it easy to transfer knowledge from another product without interfering with ease of use.
Начало работы с библиотекой пользовательского интерфейса Windows 2.x Getting started with the Windows UI 2.x Library
WinUI 2.5 — это последняя стабильная версия WinUI, ее следует использовать для приложений в рабочей среде. WinUI 2.5 is the latest stable version of WinUI and should be used for apps in production.
Эта библиотека доступна в виде пакета NuGet, который можно добавить в любой новый или существующий проект Visual Studio. The library is available as a NuGet package that can be added to any new or existing Visual Studio project.
Дополнительные сведения о возможности ознакомления с предварительными версиями WinUI 3 см. в статье Библиотека пользовательского интерфейса Windows 3, предварительная версия 4 (февраль 2021 г.). For more information on trying out early previews of WinUI 3, see Windows UI Library 3 Preview 4 (February 2021).
Загрузка и установка библиотеки пользовательского интерфейса Windows Download and install the Windows UI Library
Скачайте Visual Studio 2019 и убедитесь, что в установщике Visual Studio выбрана рабочая нагрузка Разработка приложений для универсальной платформы Windows. Download Visual Studio 2019 and ensure you choose the Universal Windows Platform development Workload in the Visual Studio installer.
Откройте существующий проект или создайте новый проект с помощью шаблона «Пустое приложение» в Visual C# -> Windows -> Универсальный, или соответствующий шаблон для вашей языковой проекции. Open an existing project, or create a new project using the Blank App template under Visual C# -> Windows -> Universal, or the appropriate template for your language projection.
Чтобы использовать WinUI 2.5, в свойствах проекта нужно задать TargetPlatformVersion >= 10.0.18362.0 и TargetPlatformMinVersion >= 10.0.15063.0. To use WinUI 2.5, you must set TargetPlatformVersion >= 10.0.18362.0 and TargetPlatformMinVersion >= 10.0.15063.0 in the project properties.
На панели обозревателя решений щелкните название проекта правой кнопкой мыши и выберите Управление пакетами NuGet. In the Solution Explorer panel, right click on your project name and select Manage NuGet Packages.
Панель Обозревателя решений с открытым с помощью щелчка правой кнопкой проектом и выделенным параметром «Управление пакетами NuGet». The Solution Explorer panel with the project right-clicked and the Manage NuGet Packages option highlighted.
В диспетчере пакетов NuGet перейдите на вкладку Обзор и выполните поиск по запросу Microsoft.UI.Xaml или WinUI. In the NuGet Package Manager, select the Browse tab and search for Microsoft.UI.Xaml or WinUI. Выберите нужные пакеты NuGet для библиотеки пользовательского интерфейса Windows (пакет Microsoft.UI.Xaml содержит элементы управления и функции, которые подходят для любых приложений). Select which Windows UI Library NuGet Packages you want to use (the Microsoft.UI.Xaml package contains Fluent controls and features suitable for all apps). Нажмите кнопку «Установить». Click Install.
Установите флажок «Включить предварительные выпуски», чтобы просмотреть последние предварительные версии, включающие экспериментальные новые функции. Check the «Include prerelease» checkbox to see the latest prerelease versions that include experimental new features.
Диалоговое окно диспетчера пакетов NuGet с открытой вкладкой «Обзор», в поле поиска которой отображается запись «winui», и флажком «Включить предварительные выпуски». The NuGet Package Manager dialog box showing the Browse tab with winui in the search field and Include prerelease checked.
Добавьте ресурсы темы пользовательского интерфейса Windows (WinUI) в файл App.xaml. Add the Windows UI (WinUI) Theme Resources to your App.xaml file.
Это можно сделать двумя способами, в зависимости от наличия дополнительных ресурсов приложения. There are two ways to do this, depending on whether you have additional application resources.
a. a. Если вам не нужны другие ресурсы приложений, добавьте элемент ресурсов WinUI как показано в следующем примере: If you don’t need other application resources, add the WinUI resources element as shown in the following example:
b. b. Если нужны несколько ресурсов приложения, добавьте элемент ресурсов WinUI в , как показано ниже: If you need more than one application resource, add the WinUI resources element in a as shown here:
Порядок, в котором ресурсы добавляются в ResourceDictionary, влияет на порядок, в котором они применяются. The order of resources added to a ResourceDictionary affects the order in which they are applied. Словарь XamlControlsResources переопределяет множество ключей ресурсов по умолчанию и поэтому должен быть добавлен к Application.Resources , чтобы не переопределять другие пользовательские стили или ресурсы в приложении. The XamlControlsResources dictionary overrides many default resource keys and should therefore be added to Application.Resources first so that it doesn’t override any other custom styles or resources in your app. Дополнительные сведения о загрузке ресурсов см. в статье Ссылки на ресурсы ResourceDictionary и XAML. For more information on resource loading, see ResourceDictionary and XAML resource references.
Добавьте ссылку на пакет WinUI на страницы XAML и (или) страницы кода программной части. Add a reference to the WinUI package to both XAML pages and/or code-behind pages.
На странице XAML добавьте ссылку в верхней части страницы. In your XAML page, add a reference at the top of your page
В коде (если вы хотите использовать имена типов без их уточнения), можно добавить директиву using. In your code (if you want to use the type names without qualifying them), you can add a using directive.
Дополнительные шаги для проекта C++/WinRT Additional steps for a C++/WinRT project
Когда вы добавляете пакет NuGet в проект C++/WinRT, средство создает набор заголовков проекции в папке проекта \Generated Files\winrt . When you add a NuGet package to a C++/WinRT project, the tooling generates a set of projection headers in your project’s \Generated Files\winrt folder. Чтобы поместить эти файлы с заголовками в свой проект и чтобы ссылки на эти новые типы работали, можно перейти к предварительно откомпилированному файлу заголовка (обычно pch.h ) и включить их в файл проекта. To bring those headers files into your project, so that references to those new types resolve, you can go into your precompiled header file (typically pch.h ) and include them. Ниже приведен пример, включающий созданные файлы заголовков для пакета Microsoft.UI.Xaml. Below is an example that includes the generated header files for the Microsoft.UI.Xaml package.
Полное пошаговое руководство по добавлению простой поддержки библиотеки пользовательского интерфейса Windows в проект C++/WinRT см. в статье Простой пример библиотеки пользовательского интерфейса Windows для C++/WinRT. For a full, step-by-step walkthrough of adding simple support for the Windows UI Library to a C++/WinRT project, see A simple C++/WinRT Windows UI Library example.
Дополнение к библиотеке пользовательского интерфейса Windows Contributing to the Windows UI Library
WinUI — проект с открытым кодом, размещенный на сайте GitHub. WinUI is an open source project hosted on GitHub.
Мы рады любым сообщениям об ошибках, запросам на добавление функций и вкладам сообщества в создание кода, вносимым в репозиторий библиотеки пользовательского интерфейса Windows. We welcome bug reports, feature requests and community code contributions in the Windows UI Library repo.
Другие ресурсы Other resources
Если вы не знакомы с UWP, рекомендуем ознакомится со статьей Приступая к работе с приложениями для Windows 10 на портале разработчика. If you’re new to UWP, then we recommend that you visit the Getting Started with UWP Development pages on the Developer portal.