Reputation: 1035
I've been doing a lot of reading into WPF drawing and performance and it's apparent that some methods of drawing are better than others. I have however gotten confused with different people's terminology of things and just want to clarify one issue.
The system I'm working on has lots of gauges on a screen (exactly like a speedometer in a car). The scale and range indicators can change and are different on each gauge. Is it best to draw these in the xaml or in the .cs file behind it. The reason I'm asking is that we are starting to see performance issues in the system when a lot of gauges are on display and I'm trying to isolate the cause.
Currently it's drawn behind with each individual segment added like children.add(UIElement)
.
Upvotes: 0
Views: 287
Reputation: 501
I'm not sure if placing them in the xaml or the code behind makes a difference - at the end of the day these objects get pushed onto the visual layer one way or another.
Your issue is more likely because you're using fully blown UIElement instances.
For performance enhancements, try using more light-weight objects, i.e. DrawingVisual
These objects are not as powerful as UIElements, so you may lose some functionality that you want to use that you'll need to reimplement another way.
This documentation should put you on the right track.
Upvotes: 1