Probably you should not expect that TranslateTransform is the only possible value for RenderTransform. It depends on previous operations.
Maybe you can use something like this: PreviousX = DraggingDot.RenderTransform.Value.OffsetX.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a UserControl that includes code that allows it to be moved on a map. This functionality has been working for months but - all of a sudden - it throws a run-time error. Here is the code:
Private Sub DotMouseLeftButtonUp(ByVal sender As Object, ByVal e As MouseButtonEventArgs) Handles Me.MouseLeftButtonUp
IsDragging = False
Dim DraggingDot As Dot = DirectCast(sender, Dot)
Dim Translate As TranslateTransform = DirectCast(DraggingDot.RenderTransform, TranslateTransform)
PreviousX = Translate.X
PreviousY = Translate.Y
DraggingDot.ReleaseMouseCapture()
End Sub
The line #4 throws this error:
System.InvalidCastException
HResult=0x80004002
Message=Unable to cast object of type 'System.Windows.Media.MatrixTransform' to type 'System.Windows.Media.TranslateTransform'.
So what's changed, you ask. Last night Microsoft upgraded Windows 10 to the latest release. I really don't like the new theme; but I digress. Nothing else (that I know of) has changed. Could that be the source of the problem? If so, should I report this to Microsoft?
Probably you should not expect that TranslateTransform is the only possible value for RenderTransform. It depends on previous operations.
Maybe you can use something like this: PreviousX = DraggingDot.RenderTransform.Value.OffsetX.
Last Comment: I replaced the XAML and vb files for the UseerControl from a backuip. That fixed all the problems. I can only conclude that some non-printing garbage got into the file which then caused all the havoc.