Click here to Skip to main content
15,891,981 members
Home / Discussions / WPF
   

WPF

 
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 
QuestionCode only working with break points Pin
Dominick Marciano9-Jan-15 19:14
professionalDominick Marciano9-Jan-15 19:14 
AnswerRe: Code only working with break points Pin
SledgeHammer019-Jan-15 19:15
SledgeHammer019-Jan-15 19:15 
AnswerRe: Code only working with break points Pin
Afzaal Ahmad Zeeshan9-Jan-15 20:29
professionalAfzaal Ahmad Zeeshan9-Jan-15 20:29 
QuestionAnybody using DwmExtendFrameIntoClientArea? Pin
SledgeHammer019-Jan-15 11:59
SledgeHammer019-Jan-15 11:59 
AnswerRe: Anybody using DwmExtendFrameIntoClientArea? Pin
Richard Deeming12-Jan-15 2:31
mveRichard Deeming12-Jan-15 2:31 
GeneralRe: Anybody using DwmExtendFrameIntoClientArea? Pin
SledgeHammer0112-Jan-15 4:52
SledgeHammer0112-Jan-15 4:52 
QuestionWhere to go to learn wpf? Pin
MrGlass35-Jan-15 8:44
MrGlass35-Jan-15 8:44 
AnswerRe: Where to go to learn wpf? Pin
SledgeHammer015-Jan-15 9:59
SledgeHammer015-Jan-15 9:59 
AnswerRe: Where to go to learn wpf? Pin
Mycroft Holmes5-Jan-15 12:11
professionalMycroft Holmes5-Jan-15 12:11 
GeneralRe: Where to go to learn wpf? Pin
SledgeHammer015-Jan-15 12:58
SledgeHammer015-Jan-15 12:58 

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.