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

WPF

 
GeneralRe: Why does WPF ignore stuff? Pin
Mark Salsbery2-Apr-09 5:49
Mark Salsbery2-Apr-09 5:49 
GeneralRe: Why does WPF ignore stuff? Pin
RugbyLeague2-Apr-09 5:51
RugbyLeague2-Apr-09 5:51 
QuestionUse .XAP file in ASP.Net Website Pin
pavanip2-Apr-09 2:42
pavanip2-Apr-09 2:42 
AnswerRe: Use .XAP file in ASP.Net Website Pin
Mark Salsbery2-Apr-09 5:21
Mark Salsbery2-Apr-09 5:21 
QuestionWPF codes to play a RTSP multicast or unicast video stream Pin
jklanka1-Apr-09 21:48
jklanka1-Apr-09 21:48 
QuestionKeep element in canvas when dragging it Pin
Pauwels Bart1-Apr-09 20:19
Pauwels Bart1-Apr-09 20:19 
AnswerRe: Keep element in canvas when dragging it Pin
ABitSmart1-Apr-09 21:17
ABitSmart1-Apr-09 21:17 
QuestionRe: Keep element in canvas when dragging it Pin
Pauwels Bart1-Apr-09 23:30
Pauwels Bart1-Apr-09 23:30 
I hadn't tried it before but ClipToBounds doesn't work.

When I add a new UIElement (like an image) to the Canvas, I adorn it. That adorner adds a Thumb to each side of the UIElement and that thumbs handles the drag function.


// Handler for moving.
private void HandleMove(object sender, DragDeltaEventArgs args)
{
    // Horizontal position.
    if (StanagCanvas.GetLeft(this.AdornedElement) + args.HorizontalChange < 0)
    {
        // Crossing left boundary.
        StanagCanvas.SetLeft(this.AdornedElement, 0);
    }
    else if (StanagCanvas.GetRight(this.AdornedElement) - args.HorizontalChange < 0)
    {
        // Crossing right boundary.
        StanagCanvas.SetRight(this.AdornedElement, 0);
    }
    else
    {
        StanagCanvas.SetLeft(this.AdornedElement, StanagCanvas.GetLeft(this.AdornedElement) + args.HorizontalChange);
    }

    // Vertical position.
    if (StanagCanvas.GetTop(this.AdornedElement) + args.VerticalChange < 0)
    {
        // Crossing top boundary.
        StanagCanvas.SetTop(this.AdornedElement, 0);
    }
    else if (StanagCanvas.GetBottom(this.AdornedElement) - args.VerticalChange < 0)
    {
        // Crossing bottom boundary.
        StanagCanvas.SetBottom(this.AdornedElement, 0);
    }
    else
    {
        StanagCanvas.SetTop(this.AdornedElement, StanagCanvas.GetTop(this.AdornedElement) + args.VerticalChange);
    }
}

(StanagCanvas derives from Canvas)

Offcourse the Right and Bottom properties don't work because I allready use the Left and Top properties. The element doesn't cross the left and top boundery of the canvas.

I hope this is enough information.
AnswerRe: Keep element in canvas when dragging it Pin
ABitSmart2-Apr-09 5:05
ABitSmart2-Apr-09 5:05 
QuestionRe: Keep element in canvas when dragging it Pin
Pauwels Bart2-Apr-09 7:22
Pauwels Bart2-Apr-09 7:22 
AnswerRe: Keep element in canvas when dragging it [modified] Pin
ABitSmart2-Apr-09 7:50
ABitSmart2-Apr-09 7:50 
GeneralRe: Keep element in canvas when dragging it Pin
Pauwels Bart2-Apr-09 8:45
Pauwels Bart2-Apr-09 8:45 
GeneralRe: Keep element in canvas when dragging it Pin
Pauwels Bart4-Apr-09 18:32
Pauwels Bart4-Apr-09 18:32 
GeneralRe: Keep element in canvas when dragging it Pin
ABitSmart4-Apr-09 19:42
ABitSmart4-Apr-09 19:42 
GeneralRe: Keep element in canvas when dragging it Pin
Pauwels Bart4-Apr-09 19:54
Pauwels Bart4-Apr-09 19:54 
QuestionWPF or Windows Forms Pin
dfreeser1-Apr-09 12:00
dfreeser1-Apr-09 12:00 
AnswerRe: WPF or Windows Forms Pin
Pete O'Hanlon1-Apr-09 22:03
mvePete O'Hanlon1-Apr-09 22:03 
AnswerRe: WPF or Windows Forms Pin
RugbyLeague2-Apr-09 5:40
RugbyLeague2-Apr-09 5:40 
GeneralRe: WPF or Windows Forms Pin
dfreeser2-Apr-09 5:56
dfreeser2-Apr-09 5:56 
QuestionSet style definition dynamically Pin
salon1-Apr-09 3:46
salon1-Apr-09 3:46 
AnswerRe: Set style definition dynamically Pin
Mark Salsbery1-Apr-09 7:42
Mark Salsbery1-Apr-09 7:42 
GeneralRe: Set style definition dynamically Pin
salon1-Apr-09 20:48
salon1-Apr-09 20:48 
GeneralRe: Set style definition dynamically Pin
Mark Salsbery2-Apr-09 5:26
Mark Salsbery2-Apr-09 5:26 
QuestionSys.InvalidOprationException.ManageRunTimeError error #4004 in control 'Xaml1 Pin
Piyush Vardhan Singh1-Apr-09 0:17
Piyush Vardhan Singh1-Apr-09 0:17 
AnswerRe: Sys.InvalidOprationException.ManageRunTimeError error #4004 in control 'Xaml1 Pin
Piyush Vardhan Singh1-Apr-09 2:02
Piyush Vardhan Singh1-Apr-09 2:02 

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.