Lenguaje

ThemeSettings Clase

Definición

La API ThemeSettings permite que las aplicaciones win32 Windows Runtime detecten que la configuración de contraste alto del sistema ha cambiado.

public ref class ThemeSettings sealed
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Foundation.WindowsAppSDKContract, 65540)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class ThemeSettings final
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Foundation.WindowsAppSDKContract), 65540)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class ThemeSettings
Public NotInheritable Class ThemeSettings
Herencia
Object Platform::Object IInspectable ThemeSettings
Atributos

Ejemplos

En este código de ejemplo, una aplicación usa un objeto ThemeSettings para escuchar los cambios de contraste alto en el sistema:

void MyApp::ListenForHighContrastChange(XamlRoot& xamlRoot) 
{
  const auto myWindowId = xamlRoot.ContentIslandEnvironment().AppWindowId();
  m_themeSettings = ThemeSettings::CreateForWindowId(myWindowId);

  m_themeSettings.Changed([xamlRoot](const ThemeSettings& ts, const auto&) {
    if (ts.HighContrast())
    {
      ::OutputDebugString(L"High contrast is ON, scheme is: ");
      ::OutputDebugString(ts.HighContrastScheme().c_str());
    }
    else
    {
      ::OutputDebugString(L"High contrast is OFF.\n");
    }
  });
}
void MyApp.ListenForHighContrastChange(XamlRoot xamlRoot)
{
    var myWindowId = xamlRoot.ContentIslandEnvironment().AppWindowId();
    m_themeSettings = ThemeSettings.CreateForWindowId(myWindowId);

    m_themeSettings.Changed += (ts, _) =>
    {
        if (ts.HighContrast())
        {
            Debug.WriteLine("High contrast is ON, scheme is: ");
            Debug.WriteLine(ts.HighContrastScheme());
        }
        else
        {
            Debug.WriteLine("High contrast is OFF.");
        }
    };
}

Comentarios

Cuando la aplicación libera todas sus referencias a un objeto ThemeSettings , el objeto se destruirá y el evento Changed ya no se activará.

Propiedades

Nombre Description
HighContrast

Obtiene la configuración actual contraste alto.

HighContrastScheme

Esquema o estilo de contraste alto del sistema, si se aplica uno actualmente.

Métodos

Nombre Description
CreateForWindowId(WindowId)

Crea un objeto ThemeSettings que proporcionará información de tema para el WindowId especificado.

Eventos

Nombre Description
Changed

Este evento se genera cuando se ha cambiado una de las propiedades del objeto ThemeSettings .

Se aplica a

Consulte también