ThemeSettings クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
ThemeSettings API を使用すると、Win32 Windows ランタイム アプリはシステムのハイ コントラスト設定が変更されたことを検出できます。
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
- 継承
- 属性
例
このサンプル コードでは、アプリは ThemeSettings オブジェクトを使用して、システムのハイ コントラストの変更をリッスンします。
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.");
}
};
}
注釈
アプリが ThemeSettings オブジェクトへのすべての参照を解放すると、オブジェクトは破棄され、 Changed イベントは発生しなくなります。
プロパティ
| 名前 | 説明 |
|---|---|
| HighContrast |
現在のハイ コントラスト設定を取得します。 |
| HighContrastScheme |
システムのハイ コントラスト スキームまたはスタイル (現在適用されている場合)。 |
メソッド
| 名前 | 説明 |
|---|---|
| CreateForWindowId(WindowId) |
指定された WindowId のテーマ情報を提供する ThemeSettings オブジェクトを作成します。 |
イベント
| 名前 | 説明 |
|---|---|
| Changed |
このイベントは、 ThemeSettings オブジェクトのプロパティのいずれかが変更されたときに発生します。 |