Click here to Skip to main content
15,886,017 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Application.Run C# equivalent Pin
GregJ717-Apr-18 11:52
GregJ717-Apr-18 11:52 
GeneralRe: Application.Run C# equivalent Pin
Richard MacCutchan17-Apr-18 20:53
mveRichard MacCutchan17-Apr-18 20:53 
GeneralRe: Application.Run C# equivalent Pin
GregJ718-Apr-18 1:24
GregJ718-Apr-18 1:24 
GeneralRe: Application.Run C# equivalent Pin
Richard MacCutchan18-Apr-18 1:37
mveRichard MacCutchan18-Apr-18 1:37 
AnswerRe: Application.Run C# equivalent Pin
Pete O'Hanlon18-Apr-18 1:52
mvePete O'Hanlon18-Apr-18 1:52 
GeneralRe: Application.Run C# equivalent Pin
GregJ718-Apr-18 1:57
GregJ718-Apr-18 1:57 
GeneralRe: Application.Run C# equivalent Pin
Pete O'Hanlon18-Apr-18 2:01
mvePete O'Hanlon18-Apr-18 2:01 
QuestionDragDrop In A Canvas Pin
Kevin Marois11-Apr-18 8:36
professionalKevin Marois11-Apr-18 8:36 
I'm trying to drag a user control around a canvas. I want to prevent the user from dragging the control outside the canvas.. See my comment in green.
private void Control_MouseMove(object sender, MouseEventArgs e)
{
    var draggableControl = sender as UserControl;

    if (isDragging && draggableControl != null)
    {
        Point currentPosition = e.GetPosition(this.Parent as UIElement);

        var transform = draggableControl.RenderTransform as TranslateTransform;
        if (transform == null)
        {
            transform = new TranslateTransform();
            draggableControl.RenderTransform = transform;
        }

        // Problem: currentPosition is the distance from the window's Left edge, 
        // not the left edge of the canvas
        var newX = currentPosition.X - clickPosition.X; 
        if (newX < 0)
        {
            newX = 0;
        }
        if (newX > parent.ActualWidth)
        {
            newX = parent.Width - this.Width;
        }
        transform.X = newX;
        transform.Y = currentPosition.Y - clickPosition.Y;
    }
}
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.

AnswerRe: DragDrop In A Canvas Pin
Mycroft Holmes11-Apr-18 14:18
professionalMycroft Holmes11-Apr-18 14:18 
GeneralRe: DragDrop In A Canvas Pin
Kevin Marois12-Apr-18 5:50
professionalKevin Marois12-Apr-18 5:50 
QuestionAbout drag-and-drop issues Pin
Member 1300190328-Mar-18 17:31
Member 1300190328-Mar-18 17:31 
AnswerRe: About drag-and-drop issues Pin
Richard Deeming29-Mar-18 3:04
mveRichard Deeming29-Mar-18 3:04 
GeneralRe: About drag-and-drop issues Pin
Member 1300190329-Mar-18 20:26
Member 1300190329-Mar-18 20:26 
GeneralRe: About drag-and-drop issues Pin
Gerry Schmitz2-Apr-18 7:18
mveGerry Schmitz2-Apr-18 7:18 
GeneralRe: About drag-and-drop issues Pin
Pete O'Hanlon2-Apr-18 7:50
mvePete O'Hanlon2-Apr-18 7:50 
GeneralRe: About drag-and-drop issues Pin
Gerry Schmitz2-Apr-18 8:08
mveGerry Schmitz2-Apr-18 8:08 
GeneralRe: About drag-and-drop issues Pin
Member 130019032-Apr-18 17:25
Member 130019032-Apr-18 17:25 
GeneralRe: About drag-and-drop issues Pin
Pete O'Hanlon2-Apr-18 22:45
mvePete O'Hanlon2-Apr-18 22:45 
QuestionUse dependency properties with a WPF custom control Pin
bytesport27-Mar-18 23:18
bytesport27-Mar-18 23:18 
Rant[REPOST] Use dependency properties with a WPF custom control Pin
Richard Deeming28-Mar-18 7:58
mveRichard Deeming28-Mar-18 7:58 
QuestionWPF DataGrid Group Summary Rows Pin
Kevin Marois19-Mar-18 17:26
professionalKevin Marois19-Mar-18 17:26 
AnswerRe: WPF DataGrid Group Summary Rows Pin
Mycroft Holmes19-Mar-18 21:58
professionalMycroft Holmes19-Mar-18 21:58 
GeneralRe: WPF DataGrid Group Summary Rows Pin
Kevin Marois20-Mar-18 5:01
professionalKevin Marois20-Mar-18 5:01 
GeneralRe: WPF DataGrid Group Summary Rows Pin
Mycroft Holmes20-Mar-18 12:29
professionalMycroft Holmes20-Mar-18 12:29 
AnswerRe: WPF DataGrid Group Summary Rows Pin
Gerry Schmitz20-Mar-18 8:14
mveGerry Schmitz20-Mar-18 8:14 

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.