Getting mouse position relative to grid that's scrollable
So my grid at this point dynamically expands to whatever height and I can scroll down to get coordinates using e.GetPosition(mainGrid) relative to the grid. It works fine up until when I scroll. I'll give an example.
I have a grid with some image in the background. The grid's height at this point is 950. If I drag my selection square at the very bottom of the grid and get the position relative to it (e.GetPosition(mainGrid)), I get 950. Great.
Now, when I resize past 950, to let's say 1200, I have to scroll down to see the rest of my grid. I do the same thing, draw a selection square at the bottom of my grid expecting my Y-coordinate to be 1200 but instead always get a Y-coordinate of 950. In other words, the offset of which I scrolled to is not being applied to the Y-coordinate and I am unsure of how to do indicate this. I pretty much want to say to WPF "Get the position relative to the grid but make 开发者_如何学JAVAsure that you get it always from the origin at the upper-left of grid at 0,0 and not just the portion of the grid that is visible to you".
Fixed. I have an outer grid acting as my container and an inner grid. I was targeting the outer grid thinking it would change in size too when the inner grid changed size but I guess not. Works now by targeting the inner grid.
精彩评论