Canvas, dragging, scrollbars and measureoverride
-
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.
-
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.
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.
-
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.
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[^]