I have a class in a UWP Project that derives from Windows.UI.Xaml.Shapes.Shape:
public class Hex : Windows.UI.Xaml.Shapes.Shape
{
public Hex()
{
}
}
When I tried to instantiate a new memeber of this class in mainPage.cs I get an InvalidCastException as following:
System.InvalidCastException: Specified cast is not valid.
at Windows.UI.Xaml.Shapes.Shape..ctor()
at App1.Hex..ctor()
at App1.MainPage.Button_Click(Object sender, RoutedEventArgs e)
Here is the code from mainPage.cs
private void Button_Click(object sender, RoutedEventArgs e)
{
var h = new Hex();
h.Width = 20;
}
but doesn't work neither. As I understand the protected constructor of Shape should be able to be accessed from a derived class, so what's happening? Doing the same thing with deriving from Windows.UI.Xaml.Frameworkelemnt works without problems.