c# - Need to detect drop location in reference to Grid Element in WPF -
i creating grid elements dynamically onto stack panel. when object dropped on stack panel, fires event needs determine drop point in reference grid element on stackpanel. using wpf, might make answers different.
for example, have following code called when object dropped onto grid element(that has been created dynamically).
/*handles drop event grid item*/ private void grid_drop(object sender,drageventargs e) { object droppeddata = e.getdata(typeof(object)); //this part not important /*get grid dropped on*/ grid grid = (grid)sender; /*translate drop point in reference stack panel*/ point droppoint = this.translatepoint(e.getposition(this),stackpanel)); }
here have stopped, need calculate following
if droppoint above middle point of grid else if droppoint below middle point of grid
why don't relative position grid, rather stack panel , compare point.y grid.actualheight/2 see if above or below?
Comments
Post a Comment