views:

111

answers:

2

Hi I have some problems with implementing autoscrolling in WPF (I think I could call it that way). I have a canvas placed inside a scrollviwer. On my canvas I can dynamicly add different shapes. The position of this shapes can be changed with mouse. Everytime I add new shape on canvas or change position of shape I fire measureOverride function.Thanks to this scrollview "know" the real size of canvas and the scrollbars appear. However even if scrolbars appear, the view doesn't "follow" shape which I currently move. I mean if I reach visible part of canvas I would like canvas to srcoll. I was trying to use this function

ScrollToHorizontalOffset()

However I have problem with proper use of that function. I was trying to use (as a parameter) canvas actualwidth but it didn't work well. I also was trying to use as a parameter current position of shape (which I move) but it works only one way. I the viewer follow the moving element if I was moving this element to right side of canvas. However if I move shape back(to the left) the view don't follow the shape.

I hope somebody will understand this :) It is hard to explain my problem.

A: 

I also was trying to use as a parameter current position of shape

That is the correct way to implement. Waht you need is a converter, which will returns the position according to the direction you move the object.

Avatar
A: 

Could You give me some more details. Example maybe ?

elMariachi