Pregunta

¿Hay alguna forma de saber si el usuario ha seleccionado un tema claro o oscuro?

¡Gracias!

¿Fue útil?

Solución

Hay una propiedad para probar esto, en lugar de comparar el color de recursos real.

Visibility v = (Visibility)Resources["PhoneLightThemeVisibility"]; 

if (v == System.Windows.Visibility.Visible)
{
    // Is light theme
}
else
{
    // Is dark theme
}

Otros consejos

Si tiene la intención de detectar el tema en código, aquí hay una solución -

var backColor = Resources["PhoneBackgroundColor"];
if (backColor.ToString() == "#FF000000")
    // Dark theme selected => do something
else
    // Light theme selected => do something

Hth, indyfromoz

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top