当我打开一个弹出窗口时,我正在使用以下代码在窗口上设置灰光效果。它工作正常,但它基本上重新加载所有控件或刷新主窗口。
特别是这一行:currentWindow.Content = lightboxGrid;
Window currentWindow = Application.Current.Windows.Cast<Window>()
.SingleOrDefault(x => x.Name.Equals(MAIN_WINDOW_NAME));
Grid lightboxGrid = new Grid();
object currentWindowContent = currentWindow.Content;
currentWindow.Content = null;
lightboxGrid.Children.Add(new ContentControl()
{
Content = currentWindowContent
});
// now add the grid that will "black out" the content
Grid blackoutGrid = new Grid();
blackoutGrid.Background = new SolidColorBrush(Colors.Black);
lightboxGrid.Children.Add(blackoutGrid);
blackoutGrid.Opacity = 0.0; // start fully transparent
blackoutGrid.Loaded += blackoutGrid_Loaded;
currentWindow.Content = lightboxGrid;
this._lightboxEffectApplied = true;
在不刷新主窗口或重新加载控件的情况下具有相同效果的选项是什么?