Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Canvas, dragging, scrollbars and measureoverride

Canvas, dragging, scrollbars and measureoverride

Scheduled Pinned Locked Moved WPF
help
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RugbyLeague
    wrote on last edited by
    #1

    I have a custom canvas control which sits inside a scrollviewer - I have implemented drag, drop and move for items on the canvas and overridden MeasureOverride so that when I move an item around on the canvas its size reflects the changes so if I move the item beyond the visible portion of the canvas it will resize to accomodate the moved item and scrollbars will show appropriately. However if I then bring the item into view by using the scrollbars then start to move the item back out again the scrollbars go a bit haywire. It's a rather poor explanation of the problem I afraid but I am not sure how else to put it but hopefully it will contain enough info for somebody to point me in the right direction.

    P 1 Reply Last reply
    0
    • R RugbyLeague

      I have a custom canvas control which sits inside a scrollviewer - I have implemented drag, drop and move for items on the canvas and overridden MeasureOverride so that when I move an item around on the canvas its size reflects the changes so if I move the item beyond the visible portion of the canvas it will resize to accomodate the moved item and scrollbars will show appropriately. However if I then bring the item into view by using the scrollbars then start to move the item back out again the scrollbars go a bit haywire. It's a rather poor explanation of the problem I afraid but I am not sure how else to put it but hopefully it will contain enough info for somebody to point me in the right direction.

      P Offline
      P Offline
      PumbaPumba
      wrote on last edited by
      #2

      Hi RugbyLeague, I could understand the problem. You are having a visual studio designer like custom canvas control, in which you will be having controls. The problem is with scrollbar of the scroll viewer in which the canvas is hosted. Right?

      RugbyLeague wrote:

      bit haywire.

      Do you mean, the scroll bars of the scroll viewer not scrolling smoothly? If that is the case. So far known best way is, You have to create your own calculation for updating the scrollviewer's vertical and horizontal offset.

      R 1 Reply Last reply
      0
      • P PumbaPumba

        Hi RugbyLeague, I could understand the problem. You are having a visual studio designer like custom canvas control, in which you will be having controls. The problem is with scrollbar of the scroll viewer in which the canvas is hosted. Right?

        RugbyLeague wrote:

        bit haywire.

        Do you mean, the scroll bars of the scroll viewer not scrolling smoothly? If that is the case. So far known best way is, You have to create your own calculation for updating the scrollviewer's vertical and horizontal offset.

        R Offline
        R Offline
        RugbyLeague
        wrote on last edited by
        #3

        If I move an object down to the right hand corner of the canvas then further so I can't see the object the scrollbars react accordingly. If I then bring the object into view by using the scrollbars then move the object again its as though the scrollbars think the object is back in the original viewable area of the canvas and disappear. if I then move the object to the bottom right again the scrollbars reappear but are out of synch with where they think the object is. Similar behaviour is seen in the app in this article: WPF Diagram Designer - Part 2[^]

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups