public override void BeforeRender(WpfDrawingRenderer renderer) { base.BeforeRender(renderer); WpfDrawingContext context = renderer.Context; Geometry clipGeom = this.ClipGeometry; Transform transform = this.Transform; SvgUseElement useElement = (SvgUseElement)_svgElement; string elementId = this.GetElementName(); float opacityValue = -1; string opacity = useElement.GetAttribute("opacity"); if (string.IsNullOrWhiteSpace(opacity)) { opacity = useElement.GetPropertyValue("opacity"); } if (!string.IsNullOrWhiteSpace(opacity)) { opacityValue = (float)SvgNumber.ParseNumber(opacity); opacityValue = Math.Min(opacityValue, 1); opacityValue = Math.Max(opacityValue, 0); } _drawGroup = new DrawingGroup(); DrawingGroup currentGroup = context.Peek(); if (currentGroup == null) { throw new InvalidOperationException("An existing group is expected."); } currentGroup.Children.Add(_drawGroup); context.Push(_drawGroup); if (clipGeom != null || transform != null || (opacityValue >= 0 && opacityValue < 1) || (!string.IsNullOrWhiteSpace(elementId) && !context.IsRegisteredId(elementId))) { if (clipGeom != null) { _drawGroup.ClipGeometry = clipGeom; } if (transform != null) { _drawGroup.Transform = transform; } if (opacityValue >= 0 && opacityValue < 1) { _drawGroup.Opacity = opacityValue; } if (!string.IsNullOrWhiteSpace(elementId) && !context.IsRegisteredId(elementId)) { SvgObject.SetName(_drawGroup, elementId); context.RegisterId(elementId); if (context.IncludeRuntime) { SvgObject.SetId(_drawGroup, elementId); } } } }