Click here to Skip to main content
15,920,687 members
Home / Discussions / C#
   

C#

 
QuestionRe: Threading Problem Calling DB Query Pin
Richard MacCutchan10-Aug-15 21:54
mveRichard MacCutchan10-Aug-15 21:54 
AnswerRe: Threading Problem Calling DB Query Pin
Kevin Marois11-Aug-15 7:54
professionalKevin Marois11-Aug-15 7:54 
AnswerRe: Threading Problem Calling DB Query Pin
Gerry Schmitz11-Aug-15 8:46
mveGerry Schmitz11-Aug-15 8:46 
AnswerRe: Threading Problem Calling DB Query Pin
Mycroft Holmes11-Aug-15 15:04
professionalMycroft Holmes11-Aug-15 15:04 
QuestionGet new index of all columns after reorder in Listview Pin
Member 1185273110-Aug-15 0:10
Member 1185273110-Aug-15 0:10 
AnswerRe: Get new index of all columns after reorder in Listview Pin
Ravi Bhavnani10-Aug-15 2:48
professionalRavi Bhavnani10-Aug-15 2:48 
QuestionMessage Closed Pin
7-Aug-15 2:14
dilipk77-Aug-15 2:14 
QuestionTarget Framework in VS Pin
Bill 10016-Aug-15 8:32
Bill 10016-Aug-15 8:32 
AnswerRe: Target Framework in VS Pin
OriginalGriff6-Aug-15 8:44
mveOriginalGriff6-Aug-15 8:44 
GeneralRe: Target Framework in VS Pin
Bill 10016-Aug-15 8:54
Bill 10016-Aug-15 8:54 
AnswerRe: Target Framework in VS Pin
Kevin Marois6-Aug-15 9:35
professionalKevin Marois6-Aug-15 9:35 
GeneralRe: Target Framework in VS Pin
Bill 100113-Aug-15 11:57
Bill 100113-Aug-15 11:57 
GeneralRe: Target Framework in VS Pin
Kevin Marois13-Aug-15 12:00
professionalKevin Marois13-Aug-15 12:00 
GeneralRe: Target Framework in VS Pin
Bill 100113-Aug-15 12:06
Bill 100113-Aug-15 12:06 
GeneralRe: Target Framework in VS Pin
Kevin Marois13-Aug-15 12:07
professionalKevin Marois13-Aug-15 12:07 
QuestionDragging A Control - Limits Pin
Kevin Marois6-Aug-15 7:24
professionalKevin Marois6-Aug-15 7:24 
I have a WPF canvas that is as wide as the window, and want the user to be able to drag it to the right pas the right edge, but no more left than its original position.

Here's what I have so far:
private void root_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
    var element = sender as FrameworkElement;
    anchorPoint = e.GetPosition(null);
    element.CaptureMouse();
    isDragging = true;
    e.Handled = true;
}

private void root_MouseMove(object sender, MouseEventArgs e)
{
    if (isDragging)
    {
        Canvas element = sender as Canvas;
        currentPoint = e.GetPosition(null);

        transform.X += currentPoint.X - anchorPoint.X;
        transform.Y = transform.Y;
        innerCanvas.RenderTransform = transform;
        anchorPoint = currentPoint;
    }
}

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

I've tried this in MouseMove:
if (currentPoint.X - anchorPoint.X > -1)
{
    transform.X += currentPoint.X - anchorPoint.X;
    transform.Y = transform.Y;
    innerCanvas.RenderTransform = transform;
    anchorPoint = currentPoint;
}

but the control only moves once, and then no more at all after that.

How do I keep the control from being move to the left so that its right edge is never past the window's right edge?
If it's not broken, fix it until it is


modified 6-Aug-15 13:31pm.

AnswerRe: Dragging A Control - Limits Pin
Alan N7-Aug-15 8:07
Alan N7-Aug-15 8:07 
QuestionInterop.COMSVCSLib.DLL - Application Error Pin
cpremesh6-Aug-15 2:58
cpremesh6-Aug-15 2:58 
QuestionExecute keyboard shortcuts through code Pin
Member 108502535-Aug-15 15:18
Member 108502535-Aug-15 15:18 
AnswerRe: Execute keyboard shortcuts through code Pin
OriginalGriff5-Aug-15 22:33
mveOriginalGriff5-Aug-15 22:33 
GeneralRe: Execute keyboard shortcuts through code Pin
Member 108502536-Aug-15 1:40
Member 108502536-Aug-15 1:40 
GeneralRe: Execute keyboard shortcuts through code Pin
OriginalGriff6-Aug-15 1:43
mveOriginalGriff6-Aug-15 1:43 
GeneralRe: Execute keyboard shortcuts through code Pin
Member 108502536-Aug-15 1:48
Member 108502536-Aug-15 1:48 
GeneralRe: Execute keyboard shortcuts through code Pin
Member 108502536-Aug-15 1:59
Member 108502536-Aug-15 1:59 
GeneralRe: Execute keyboard shortcuts through code Pin
OriginalGriff6-Aug-15 2:11
mveOriginalGriff6-Aug-15 2:11 

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.