From wpf-dev-pack
WPF rendering and performance optimization specialist. Optimizes using DrawingContext, DrawingVisual, VirtualizingStackPanel, Freezable patterns, and memory management for high-performance UIs.
npx claudepluginhub christian289/dotnet-with-claudecode --plugin wpf-dev-packsonnetOptimize WPF rendering performance and memory management for high-performance applications. ```csharp public class OptimizedCanvas : FrameworkElement { private readonly List<Point> _points = []; private Pen? _pen; private Brush? _brush; public OptimizedCanvas() { // Create and freeze resources _pen = new Pen(Brushes.Black, 1); _pen.Freeze(); _brush = Brushes.Blue.Clone(); _brush.Freeze(); } pro...Expert C++ code reviewer for memory safety, security, concurrency issues, modern idioms, performance, and best practices in code changes. Delegate for all C++ projects.
Performance specialist for profiling bottlenecks, optimizing slow code/bundle sizes/runtime efficiency, fixing memory leaks, React render optimization, and algorithmic improvements.
Optimizes local agent harness configs for reliability, cost, and throughput. Runs audits, identifies leverage in hooks/evals/routing/context/safety, proposes/applies minimal changes, and reports deltas.
Optimize WPF rendering performance and memory management for high-performance applications.
public class OptimizedCanvas : FrameworkElement
{
private readonly List<Point> _points = [];
private Pen? _pen;
private Brush? _brush;
public OptimizedCanvas()
{
// Create and freeze resources
_pen = new Pen(Brushes.Black, 1);
_pen.Freeze();
_brush = Brushes.Blue.Clone();
_brush.Freeze();
}
protected override void OnRender(DrawingContext dc)
{
base.OnRender(dc);
foreach (var point in _points)
{
dc.DrawEllipse(_brush, _pen, point, 5, 5);
}
}
public void AddPoints(IEnumerable<Point> points)
{
_points.AddRange(points);
// Call InvalidateVisual ONCE after all data added
InvalidateVisual();
}
}
public class VisualHost : FrameworkElement
{
private readonly VisualCollection _children;
public VisualHost()
{
_children = new VisualCollection(this);
}
public void AddVisual(Point position)
{
var visual = new DrawingVisual();
using (var dc = visual.RenderOpen())
{
var brush = Brushes.Red.Clone();
brush.Freeze();
dc.DrawEllipse(brush, null, position, 10, 10);
}
_children.Add(visual);
}
protected override int VisualChildrenCount => _children.Count;
protected override Visual GetVisualChild(int index) => _children[index];
}
@rules/freezable-performance.md
@rules/rendering-antipatterns.md
@rules/virtualization-patterns.md
<Border CacheMode="BitmapCache">
<Border.CacheMode>
<BitmapCache EnableClearType="True"
RenderAtScale="1"
SnapsToDevicePixels="True"/>
</Border.CacheMode>
<!-- Complex visual content -->
</Border>
// Use appropriate dispatcher priority
await Dispatcher.InvokeAsync(() =>
{
// UI update
}, DispatcherPriority.Background);
// For render updates
CompositionTarget.Rendering += OnRendering;
private void OnRendering(object sender, EventArgs e)
{
// Called every frame (~60fps)
}