我要我的按钮的旋转值。人们被建议像这样的代码
RotateTransform rTransform = MyButton.RenderTransform as RotateTransform;
double angle = rTransform.Angle;但是Compiler Thorw这个例外
An unhandled exception of type 'System.InvalidCastException' occurred in DynamicButtonP.exe.
Additional information: Unable to cast a 'System.Windows.Media.MatrixTransform' the object type 'System.Windows.Media.RotateTransform' format.为什么我不能选演员?
发布于 2016-10-26 06:04:35
您忘记初始化按钮的RenderTransform属性。它的默认值是Transform.Identity,它是一个MatrixTransform。
初始化属性,例如在XAML中:
<Button x:Name="MyButton" ...>
<Button.RenderTransform>
<RotateTransform/>
</Button.RenderTransform>
</Button>https://stackoverflow.com/questions/40254430
复制相似问题