question

BitSmithy-4663 avatar image
0 Votes"
BitSmithy-4663 asked Jramos answered

[UWP] How to convert DependencyObject on the Rectangle

I cant convert DependencyObject to Rectangle object

DependencyObject asType;
Rectangle rect = (Rectangle)asType;

Intelisense tells if it is impossible, but In documentation Rectangle inherrites from DepenencyObject

Inheritance: DependencyObject>UIElement>FrameworkElement>Shape>Rectangle


Is it possible to cast DependencyObject on Rectangle?

windows-uwp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

BitSmithy-4663 avatar image
0 Votes"
BitSmithy-4663 answered

I found the problem, in default my VS defines Rectagle as ...Drawing.Rectangle.
I forced VS to define Rectangle as shape using code:
Windows.UI.Xaml.Shapes.Rectangle rect = (Windows.UI.Xaml.Shapes.Rectangle)asType;

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

PeterFleischer-3316 avatar image
0 Votes"
PeterFleischer-3316 answered

Hi, see documentation for Rectangle in System.Drawing:

Inheritance > Object > ValueType > Rectangle

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Jramos avatar image
0 Votes"
Jramos answered

hello:

Windows.UI.Xaml.Shapes.Rectangle rect = new Windows.UI.Xaml.Shapes.Rectangle();

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.