public override void Render(RenderContext parentRenderContext) { if (OpacityMask == null && (TotalHeight > ActualHeight || TotalWidth > ActualWidth)) { SolidColorBrush brush = new SolidColorBrush { Color = Color.Black }; OpacityMask = brush; _forcedOpacityMask = true; } else if (_forcedOpacityMask && TotalHeight <= ActualHeight && TotalWidth <= ActualWidth && OpacityMask != null) { OpacityMask.Dispose(); OpacityMask = null; _opacityMaskContext.Dispose(); _opacityMaskContext = null; _forcedOpacityMask = false; } base.Render(parentRenderContext); }
/// <summary> /// Required to clip any items that are partially within the panel's bounds /// </summary> /// <param name="parentRenderContext"></param> public override void Render(RenderContext parentRenderContext) { if (OpacityMask == null && _actualPhysicalOffset != 0) { SolidColorBrush brush = new SolidColorBrush { Color = Color.Black }; OpacityMask = brush; _forcedOpacityMask = true; } else if (_forcedOpacityMask && _actualPhysicalOffset == 0 && OpacityMask != null) { OpacityMask.Dispose(); OpacityMask = null; _opacityMaskContext.Dispose(); _opacityMaskContext = null; _forcedOpacityMask = false; } base.Render(parentRenderContext); }