[UWP] How to convert DependencyObject on the Rectangle

BitSmithy 1,751 Reputation points
2020-03-22T14:39:18.293+00:00

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?

Universal Windows Platform (UWP)
0 comments No comments
{count} votes

Accepted answer
  1. BitSmithy 1,751 Reputation points
    2020-03-22T22:56:33+00:00

    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;

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Peter Fleischer (former MVP) 19,231 Reputation points
    2020-03-22T15:39:43.353+00:00

    Hi, see documentation for Rectangle in System.Drawing:

    Inheritance > Object > ValueType > Rectangle

    0 comments No comments

  2. Javier R 211 Reputation points
    2020-03-23T09:50:13.737+00:00

    hello:

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

    0 comments No comments