Sunday 15 August 2010

c# - WPF Thumb drag behaviour wrong -



c# - WPF Thumb drag behaviour wrong -

i have created thumb in wpf. utilize dragdelta event alter value using mouse click , drag.

here dragdelta code:

private void thumb_dragdelta(object sender, system.windows.controls.primitives.dragdeltaeventargs e) { myvalue = e.verticalchange; }

this works fine, however, when clicking button again, value starts @ point clicked (0). need click , drag alter value relative original. tried this:

private void thumb_dragdelta(object sender, system.windows.controls.primitives.dragdeltaeventargs e) { myvalue += e.verticalchange; }

this works when drag downwards , again, value keeps decreasing, though move mouse up. same thing when moving mouse (value increases), , move mouse downwards (value keeps increasing).

this how works:

double minleft = double.maxvalue; double mintop = double.maxvalue; double left = canvas.getleft(item); double top = canvas.gettop(item); minleft = double.isnan(left) ? 0 : math.min(left, minleft); mintop = double.isnan(top) ? 0 : math.min(top, mintop); double deltahorizontal = math.max(-minleft, e.horizontalchange); double deltavertical = math.max(-mintop, e.verticalchange);

replace container command canvas.

c# wpf

No comments:

Post a Comment