Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1075443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:16:23+00:00 2026-05-16T21:16:23+00:00

[EDIT] Alright, I edited this post since the code I posted back then had

  • 0

[EDIT]

Alright,

I edited this post since the code I posted back then had no real links with what I’m trying to do now, but the question is the same.

When I’m talking about limiting objects to a Canvas it was more like a Mouse Clipping, but as I read on many threads, this feature doesn’t exist in SL. So I searched a bit around all forums and got this link. But I wasn’t able to reproduce it all. Here is the code that is used for the Drag&Drops Events:

public class RoomImage : ContentControl
{
    public RoomImage()
    {
        DefaultStyleKey = typeof(RoomImage);
    }

    public static readonly DependencyProperty BackgroundImageProperty = DependencyProperty.Register("Source", typeof(ImageSource), typeof(RoomImage), null);
    public ImageSource BackgroundImage
    {
        get { return (ImageSource)GetValue(BackgroundImageProperty); }
        set { SetValue(BackgroundImageProperty, value); }
    }

    //Instance Drag variable

    private FrameworkElement _translateZone;
    bool _isDrag;
    Point StartingDragPoint;

    public double Top
    {
        get { return (double)GetValue(Canvas.TopProperty); }
        set { SetValue(Canvas.TopProperty, value); }
    }

    public double Left
    {
        get { return (double)GetValue(Canvas.LeftProperty); }
        set { SetValue(Canvas.LeftProperty, value); }
    }

    //Instance Drag events
    public override void OnApplyTemplate()
    {
        base.OnApplyTemplate();

        _translateZone = GetTemplateChild("PART_TranslateZone") as FrameworkElement;
        DefineDragEvents();
    }

    private void DefineDragEvents()
    {
        if (_translateZone != null)
        {
            _translateZone.MouseLeftButtonDown += new MouseButtonEventHandler(translateZone_MouseLeftButtonDown);
            _translateZone.MouseLeftButtonUp += new MouseButtonEventHandler(translateZone_MouseLeftButtonUp);
            _translateZone.MouseMove += new MouseEventHandler(translateZone_MouseMove);
        }
    }

    private void translateZone_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
        _isDrag = true;

        //start the drag
        FrameworkElement DragBar = (FrameworkElement)sender;
        DragBar.CaptureMouse();

        // drag starting point
        StartingDragPoint = e.GetPosition(this);
    }

    private void translateZone_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    {
        FrameworkElement translateZone = (FrameworkElement)sender;
        translateZone.ReleaseMouseCapture();

        _isDrag = false;
    }

    private void translateZone_MouseMove(object sender, MouseEventArgs e)
    {
        if (_isDrag)
        {
            UIElement ui = (UIElement)this.Parent;
            Point Point = e.GetPosition(ui);

            Move(Point.X - StartingDragPoint.X, Point.Y - StartingDragPoint.Y);
        }
    }

    public void Move(double left, double top)
    {
        Left = left;
        Top = top;
    }

}

I found this part of code in a tutorial where they didn’t explain the Mouse.Clip at all. I can understand it and reuse it, but I have no clue where I could set the limits. The Parent of this item is a Canvas by the way.

If anyone can provide me some sort of code, or where I should implement mine it would be great!

Thank you, Ephismen.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T21:16:24+00:00Added an answer on May 16, 2026 at 9:16 pm

    A Canvas has no size as far as its children are concerned. It is just a relative starting point for rendering. A fixed canvas size is only relevant to the parent of the Canvas.

    If you mean the objects are being drawn outside the canvas rectangle, then that is the correct behaviour for a canvas.

    To stop objects being drawn outside a canvas you need to set a clipping rectangle in the Clip property of the Canvas.

    Update:

    Here is a very nice example here of how to have a ClipToBounds attached property. That is definitely the easiest way to implement bounds clipping I have seen.

    Another update:

    So you want to just keep the child items within the parent canvas. If your items vary in size & shape that is basically collision testing with the sides and cap the min/max left/top values. How complex are the shapes you are dropping? Rectangles are obviously very easy to calculate (as are circles).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: This was accidentally posted twice. Original: VB.NET Importing Classes I've seen some code
Edit: This question was written in 2008, which was like 3 internet ages ago.
Edit: From another question I provided an answer that has links to a lot
EDIT: This was formerly more explicitly titled: - Best solution to stop Kontiki's KHOST.EXE
EDIT: This question is more about language engineering than C++ itself. I used C++
Edit: I have solved this by myself. See my answer below I have set
EDIT: Learned that Webmethods actually uses NLST, not LIST, if that matters Our business
EDIT What small things which are too easy to overlook do I need to
Edit : Solved, there was a trigger with a loop on the table (read
edit #2: Question solved halfways. Look below As a follow-up question, does anyone know

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.