I want to apply a blurr effect to a specific geometry, inside WPF UIElement OnRender method.
I have code like below.
protected override void OnRender(DrawingContext drawingContext)
{
DrawingVisual drawingVisual = new DrawingVisual();
using (var dc = drawingVisual.RenderOpen())
{
dc.DrawGeometry(null, _borderColorPen, _textGeometry);
}
drawingVisual.Effect = new BlurEffect { Radius = 5 };
// drawing geometry with blurr
drawingContext.DrawDrawing(drawingVisual.Drawing);
// drawing geometry without blurr
drawingContext.DrawGeometry(_foreColorBrush, null, _textGeometry);
}
But blurr effect does'nt work.
Why is it? And what is the best way to do something like this?