Используйте Adorner.
public class OpaqueAdorner : Adorner
{
public OpaqueAdorner(UIElement win)
: base(win)
{ }
protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
{
SolidColorBrush renderBrush = new SolidColorBrush(Colors.LightCoral);
renderBrush.Opacity = 0.3;
Pen renderPen = new Pen(new SolidColorBrush(Colors.DarkBlue), 5.0);
drawingContext.DrawRectangle(renderBrush, renderPen,
new Rect(new Point(0, 0), AdornedElement.DesiredSize));
}
}
/ * Grd - контейнер Сетка * /
private void Btn_Click(object sender, RoutedEventArgs e)
{
//GetAdornerLayer was missing ')'
AdornerLayer.GetAdornerLayer(Grd).Add(new OpaqueAdorner(Grd));
}
Объедините эту концепцию с Opened / Closed
событием Popup
.