Click here to Skip to main content
15,915,172 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: hi peoples Pin
Christian Graus6-Jun-09 12:28
protectorChristian Graus6-Jun-09 12:28 
GeneralRe: hi peoples Pin
Mark Salsbery6-Jun-09 8:10
Mark Salsbery6-Jun-09 8:10 
GeneralRe: hi peoples Pin
Christian Graus6-Jun-09 12:30
protectorChristian Graus6-Jun-09 12:30 
AnswerRe: hi peoples Pin
Mark Salsbery6-Jun-09 8:10
Mark Salsbery6-Jun-09 8:10 
QuestionWPF - Move Image With Mouse Pin
Tee1235-Jun-09 15:02
Tee1235-Jun-09 15:02 
AnswerRe: WPF - Move Image With Mouse Pin
Christian Graus5-Jun-09 23:24
protectorChristian Graus5-Jun-09 23:24 
GeneralRe: WPF - Move Image With Mouse Pin
Tee1236-Jun-09 1:30
Tee1236-Jun-09 1:30 
GeneralRe: WPF - Move Image With Mouse Pin
Mark Salsbery6-Jun-09 8:45
Mark Salsbery6-Jun-09 8:45 
<Canvas Width="300" Height="200" Background="AntiqueWhite" >
    <Image Name="image1" Source="images/Silverlight_Logo.jpg" Stretch="None" MouseLeftButtonDown="image1_MouseLeftButtonDown"  MouseMove="image1_MouseMove" MouseLeftButtonUp="image1_MouseLeftButtonUp" >
        <Image.RenderTransform>
            <TranslateTransform x:Name="imageTransform" X="0" Y="0" />
        </Image.RenderTransform>
    </Image>
</Canvas>

Point anchorPoint;
Point currentPoint;
bool isInDrag = false;

private void image1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
    FrameworkElement element = sender as FrameworkElement;
    anchorPoint = e.GetPosition(null);
    element.CaptureMouse();
    isInDrag = true;
    e.Handled = true;
}

private void image1_MouseMove(object sender, MouseEventArgs e)
{
    if (isInDrag)
    {
        FrameworkElement element = sender as FrameworkElement;
        currentPoint = e.GetPosition(null);

        imageTransform.X += (currentPoint.X - anchorPoint.X);
        imageTransform.Y += (currentPoint.Y - anchorPoint.Y);

        anchorPoint = currentPoint;
    }
}

private void image1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
    if (isInDrag)
    {
        FrameworkElement element = sender as FrameworkElement;
        element.ReleaseMouseCapture();
        isInDrag = false;
        e.Handled = true;
    }
}


Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

JokeRe: WPF - Move Image With Mouse Pin
Christian Graus6-Jun-09 12:33
protectorChristian Graus6-Jun-09 12:33 
GeneralRe: WPF - Move Image With Mouse Pin
Mark Salsbery6-Jun-09 16:10
Mark Salsbery6-Jun-09 16:10 
GeneralRe: WPF - Move Image With Mouse Pin
Tee1238-Jun-09 7:37
Tee1238-Jun-09 7:37 
GeneralRe: WPF - Move Image With Mouse Pin
Sparkling_ouc1-Sep-09 19:46
Sparkling_ouc1-Sep-09 19:46 
QuestionWPF -Button control Pin
cbe_pav5-Jun-09 3:36
cbe_pav5-Jun-09 3:36 
AnswerRe: WPF -Button control Pin
ABitSmart5-Jun-09 3:51
ABitSmart5-Jun-09 3:51 
GeneralRe: WPF -Button control Pin
#realJSOP5-Jun-09 4:04
professional#realJSOP5-Jun-09 4:04 
GeneralRe: WPF -Button control Pin
Pete O'Hanlon5-Jun-09 4:11
mvePete O'Hanlon5-Jun-09 4:11 
GeneralRe: WPF -Button control Pin
#realJSOP5-Jun-09 4:38
professional#realJSOP5-Jun-09 4:38 
GeneralRe: WPF -Button control Pin
Christian Graus5-Jun-09 23:41
protectorChristian Graus5-Jun-09 23:41 
GeneralRe: WPF -Button control Pin
#realJSOP6-Jun-09 1:06
professional#realJSOP6-Jun-09 1:06 
GeneralRe: WPF -Button control Pin
Christian Graus6-Jun-09 12:34
protectorChristian Graus6-Jun-09 12:34 
GeneralRe: WPF -Button control Pin
cbe_pav5-Jun-09 18:31
cbe_pav5-Jun-09 18:31 
GeneralRe: WPF -Button control Pin
ABitSmart5-Jun-09 18:44
ABitSmart5-Jun-09 18:44 
GeneralRe: WPF -Button control Pin
cbe_pav5-Jun-09 19:17
cbe_pav5-Jun-09 19:17 
GeneralRe: WPF -Button control Pin
ABitSmart5-Jun-09 19:23
ABitSmart5-Jun-09 19:23 
GeneralRe: WPF -Button control Pin
cbe_pav5-Jun-09 19:32
cbe_pav5-Jun-09 19:32 

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.