I am not quite sure about the differences between the classes System.Windows.Media.Drawing
and System.Windows.Shapes.Shape
. They both expose functionality related to 2D graphics in WPF. When would you choose one in your WPF application, and when would you choose the other?
A Shape
inherits from FrameworkElement and is therefore a high level object which provides features such as hit-testing, styling, layout and data binding. In contrast a Drawing does not inherit from FrameworkElemet
and doesn't support any of these features. As the documentation mentions a Drawing
is useful for lightweight visual objects. If you are creating a complex brush to use to paint areas or a background a DrawingBrush would be very efficient.
Drawings can combine text, video, images and Geometry objects (another light weight class) to create complex but very efficient and fast drawings.
In short a Drawing
is a low-level alternative to a Shape
.
As for use cases, it depends.
OnRender
you would mostly use Geometries.A Drawing
is also Freezable
and can thus be shared among threads (assuming it is frozen).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With