I\'m writing an app for the universal windows platform using the dark theme and I\'ve noticed that although I\'ve correctly set the requested theme to dark when I display a
Try the below code.
///
/// Set the Overlay background for content Dialog
///
/// Content Dialog reference
public static void SetContentDialogOverlay(UIElement subTree)
{
var hostparent = VisualTreeHelper.GetParent(subTree);
var rect = FindVisualChild(hostparent);
rect.Fill = new SolidColorBrush(Colors.Black);
rect.Opacity = 0.7;
}
///
/// Find the child element from UIContainer
///
/// Type
/// Dependency Reference
///
public static T FindVisualChild(DependencyObject depObj) where T : DependencyObject
{
if (depObj != null)
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
if (child != null && child is T)
{
return (T)child;
}
T childItem = FindVisualChild(child);
if (childItem != null) return childItem;
}
}
return null;
}
Now, Call the above method on your code behind like this----
// Based upon your access modifier i.e. public/private or protected
SetContentDialogOverlay(this);
Here, "this" represent the Content Dialog reference or you can pass the object reference of the ContectDialog.
Hope, this will help you to change the color of the Overlay. Happy Coding .. :)