Click here to Skip to main content
15,923,142 members
Home / Discussions / WPF
   

WPF

 
QuestionChanging a Label Content of Page 2 from Page in WPF Pin
Vimalsoft(Pty) Ltd17-Feb-15 2:04
professionalVimalsoft(Pty) Ltd17-Feb-15 2:04 
QuestionHow to call from Nested UserControl another UserControl Pin
LAPEC16-Feb-15 10:44
LAPEC16-Feb-15 10:44 
Answer[REPOST]: How to call from Nested UserControl another UserControl Pin
Richard Deeming16-Feb-15 11:12
mveRichard Deeming16-Feb-15 11:12 
AnswerRe: How to call from Nested UserControl another UserControl Pin
Elegantly Wasted24-Mar-15 23:53
Elegantly Wasted24-Mar-15 23:53 
QuestionXamOutlookBar and XamDataTree. Pin
micromortu16-Feb-15 3:33
micromortu16-Feb-15 3:33 
QuestionHow to convert byte arrays to excel and download it in silverlight ? Pin
Member 1088301311-Feb-15 3:56
Member 1088301311-Feb-15 3:56 
AnswerRe: How to convert byte arrays to excel and download it in silverlight ? Pin
Kenneth Haugland11-Feb-15 11:56
mvaKenneth Haugland11-Feb-15 11:56 
AnswerRe: How to convert byte arrays to excel and download it in silverlight ? Pin
Richard MacCutchan11-Feb-15 21:45
mveRichard MacCutchan11-Feb-15 21:45 
GeneralRe: How to convert byte arrays to excel and download it in silverlight ? Pin
manchanx8-Mar-15 14:04
professionalmanchanx8-Mar-15 14:04 
GeneralRe: How to convert byte arrays to excel and download it in silverlight ? Pin
Richard MacCutchan8-Mar-15 22:27
mveRichard MacCutchan8-Mar-15 22:27 
GeneralRe: How to convert byte arrays to excel and download it in silverlight ? Pin
manchanx9-Mar-15 5:20
professionalmanchanx9-Mar-15 5:20 
GeneralRe: How to convert byte arrays to excel and download it in silverlight ? Pin
Richard MacCutchan9-Mar-15 5:22
mveRichard MacCutchan9-Mar-15 5:22 
GeneralRe: How to convert byte arrays to excel and download it in silverlight ? Pin
manchanx9-Mar-15 5:30
professionalmanchanx9-Mar-15 5:30 
GeneralRe: How to convert byte arrays to excel and download it in silverlight ? Pin
Richard MacCutchan9-Mar-15 5:35
mveRichard MacCutchan9-Mar-15 5:35 
GeneralRe: How to convert byte arrays to excel and download it in silverlight ? Pin
manchanx9-Mar-15 7:49
professionalmanchanx9-Mar-15 7:49 
GeneralRe: How to convert byte arrays to excel and download it in silverlight ? Pin
Richard MacCutchan9-Mar-15 7:53
mveRichard MacCutchan9-Mar-15 7:53 
GeneralRe: How to convert byte arrays to excel and download it in silverlight ? Pin
manchanx9-Mar-15 10:18
professionalmanchanx9-Mar-15 10:18 
QuestionMove Rectangle with TranslateTransform Pin
Kenneth Haugland4-Feb-15 2:36
mvaKenneth Haugland4-Feb-15 2:36 
So I took the code from a StackOverflow[^] question:

HTML
<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Image Name="Image" Source="TwitterBirdsAttack.jpg" MouseMove="Image_MouseMove" MouseUp="Rectangle_MouseLeftButtonUp" />
        <Rectangle  Name="Rect"  Width="100" Height="100" Fill="Transparent"  Stroke="Red" StrokeThickness="5" MouseLeftButtonDown="Rectangle_MouseLeftButtonDown" MouseLeftButtonUp="Rectangle_MouseLeftButtonUp"  />
    </Grid>
</Window>


VB
Class MainWindow 

    Private moveRect As Boolean
    Private trans As TranslateTransform = Nothing
    Private originalMousePosition As Point

    Private Sub Rectangle_MouseLeftButtonDown(sender As Object, e As MouseButtonEventArgs)
        originalMousePosition = e.GetPosition(Image)
        moveRect = True
        Rect.IsHitTestVisible = False

    End Sub

    Private Sub Image_MouseMove(sender As Object, e As MouseEventArgs)
        If moveRect Then
            trans = TryCast(Rect.RenderTransform, TranslateTransform)
            If trans Is Nothing Then
                trans = New TranslateTransform()
                Rect.RenderTransform = trans
            End If

            trans.Y = -(originalMousePosition.Y - e.GetPosition(Image).Y)
            trans.X = -(originalMousePosition.X - e.GetPosition(Image).X)
        End If
    End Sub

    Private Sub Rectangle_MouseLeftButtonUp(sender As Object, e As MouseButtonEventArgs)
        moveRect = False
        Rect.IsHitTestVisible = True
    End Sub

End Class

Now, the first time I move the rectangle it behaves as expected. But once its settled in its new location, it starts over again in its original location. It did not matter what I tried, the second time I clicked the moved rectangle its settled in the middle of the screen.

I tried saving the last Transformation and use this before mouse move was initiated in Rectangle_MouseLeftButtonDown, but that didn't do any good it simply refused to move.

I'll bet its something obvious that I have missed, but I cant see it now.
AnswerRe: Move Rectangle with TranslateTransform Pin
Kenneth Haugland4-Feb-15 2:59
mvaKenneth Haugland4-Feb-15 2:59 
QuestionA Calendar day to drag and drop Pin
Zorig. A.1-Feb-15 1:45
Zorig. A.1-Feb-15 1:45 
AnswerRe: A Calendar day to drag and drop Pin
Mycroft Holmes1-Feb-15 11:53
professionalMycroft Holmes1-Feb-15 11:53 
QuestionUpdate text of one textbox to multiple textbox using XAML Pin
Ashfaque Hussain26-Jan-15 23:17
Ashfaque Hussain26-Jan-15 23:17 
AnswerRe: Update text of one textbox to multiple textbox using XAML Pin
Richard Deeming27-Jan-15 1:40
mveRichard Deeming27-Jan-15 1:40 
GeneralRe: Update text of one textbox to multiple textbox using XAML Pin
Ashfaque Hussain27-Jan-15 8:13
Ashfaque Hussain27-Jan-15 8:13 
QuestionTrouble setting cooperative level [SharpDX] Pin
Jayme6523-Jan-15 6:00
Jayme6523-Jan-15 6:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.