Share via


XamlControlsResources 类

定义

WinUI 库中控件的默认样式。

本文档适用于Windows 应用 SDK中的 WinUI 2 for UWP (for WinUI,请参阅Windows 应用 SDK命名空间) 。

public ref class XamlControlsResources sealed : ResourceDictionary
/// [Microsoft.UI.Xaml.MUXContractProperty(version=0)]
/// [Windows.Foundation.Metadata.Activatable(1)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Version(1)]
class XamlControlsResources final : ResourceDictionary
/// [Windows.Foundation.Metadata.Activatable(1)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Version(1)]
/// [Microsoft.UI.Xaml.CustomAttributes.MUXContractProperty(version=0)]
/// [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)]
/// [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallbackMethodName(value="OnPropertyChanged")]
class XamlControlsResources final : ResourceDictionary
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)]
/// [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallbackMethodName(value="OnPropertyChanged")]
/// [Windows.Foundation.Metadata.Activatable(65536, "Microsoft.UI.Xaml.XamlContract")]
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.UI.Xaml.XamlContract, 65536)]
class XamlControlsResources final : ResourceDictionary
[Microsoft.UI.Xaml.MUXContractProperty(version=0)]
[Windows.Foundation.Metadata.Activatable(1)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Version(1)]
public sealed class XamlControlsResources : ResourceDictionary
[Windows.Foundation.Metadata.Activatable(1)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Version(1)]
[Microsoft.UI.Xaml.CustomAttributes.MUXContractProperty(version=0)]
[Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)]
[Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallbackMethodName(value="OnPropertyChanged")]
public sealed class XamlControlsResources : ResourceDictionary
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)]
[Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallbackMethodName(value="OnPropertyChanged")]
[Windows.Foundation.Metadata.Activatable(65536, "Microsoft.UI.Xaml.XamlContract")]
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.UI.Xaml.XamlContract), 65536)]
public sealed class XamlControlsResources : ResourceDictionary
Public NotInheritable Class XamlControlsResources
Inherits ResourceDictionary
继承
XamlControlsResources
属性
Microsoft.UI.Xaml.MUXContractPropertyAttribute ActivatableAttribute MarshalingBehaviorAttribute ThreadingAttribute VersionAttribute Microsoft.UI.Xaml.CustomAttributes.MUXContractPropertyAttribute Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallbackAttribute Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallbackMethodNameAttribute ContractVersionAttribute

示例

提示

WinUI 3 库和 WinUI 2 库应用包括大多数 WinUI 3 和 WinUI 2 控件、特性和功能的交互式示例。

如果已安装,请单击以下链接将其打开:WinUI 3 库WinUI 2 库

如果未安装,可以从 Microsoft Store 下载 WinUI 3 库WinUI 2 库

还可以从 GitHub 获取这两种应用的源代码(对 WinUI 3 使用 main 分支,对 WinUI 2 使用 winui2 分支)。

以下代码片段演示如何指定默认控件样式。

<Application>
    <Application.Resources>
        <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"/>
    </Application.Resources>
</Application>

构造函数

XamlControlsResources()

初始化 XamlControlsResources 类的新实例。

本文档适用于Windows 应用 SDK中的 WinUI 2 for UWP (for WinUI,请参阅Windows 应用 SDK命名空间) 。

属性

ControlsResourcesVersion

获取或设置要使用的 WinUI 控件样式的版本。

本文档适用于Windows 应用 SDK中的 WinUI 2 for UWP (for WinUI,请参阅Windows 应用 SDK命名空间) 。

ControlsResourcesVersionProperty

标识 ControlsResourcesVersion 依赖属性。

本文档适用于Windows 应用 SDK中的 WinUI 2 for UWP (for WinUI,请参阅Windows 应用 SDK命名空间) 。

UseCompactResources

获取或设置控件和资源是否以更密集的布局呈现。

本文档适用于Windows 应用 SDK中的 WinUI 2 for UWP (for WinUI,请参阅Windows 应用 SDK命名空间) 。

UseCompactResourcesProperty

标识 UseCompactResources 依赖属性。

本文档适用于Windows 应用 SDK中的 WinUI 2 for UWP (for WinUI,请参阅Windows 应用 SDK命名空间) 。

Version

获取或设置要应用于 XAML 控件的样式版本。

本文档适用于Windows 应用 SDK中的 WinUI 2 for UWP (for WinUI,请参阅Windows 应用 SDK命名空间) 。

VersionProperty

标识 Version 依赖属性。

本文档适用于Windows 应用 SDK中的 WinUI 2 for UWP (for WinUI,请参阅Windows 应用 SDK命名空间) 。

方法

EnsureRevealLights(UIElement)

重要

EnsureRevealLights 可用于“要求”部分中指定的操作系统。 但是,我们不建议使用它,因为它可能会在后续版本中更改或不可用。

确保在指定元素上设置显示效果所需的环境和边框灯。

本文档适用于Windows 应用 SDK中的 WinUI 2 for UWP (for WinUI,请参阅Windows 应用 SDK命名空间) 。

适用于

另请参阅