Thumb DragCompletedEventArgs.VerticalChange doesn't take DPI into account
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
In .NET Framework 4.8 (and possibel on Core) when you drag a Thumb and handle the OnThumbDragCompleted event, the DragCompletedEventArgs.VerticalChange doesn't take DPI into account.
You need to divide the VerticalChange by the DPI factor to get the correct value.
There are reports on the internet about this issue, so I decided to log a bug:
https://social.msdn.microsoft.com/Forums/en-US/59e7ece9-e073-430a-8e12-307718077671/thumb-dragcompletedeventargshorizontalchange-not-scaling-to-screen-dpi?forum=wpf
My workaround is:
```
public static (double dpiX, double dpiY) GetDPI(Visual visual)
{
var source = PresentationSource.FromVisual(visual);
var transformToDevice = source.CompositionTarget.TransformToDevice;
double dpiX = transformToDevice.M11;
double dpiY = transformToDevice.M22;
return (dpiX, dpiY);
}
void OnThumbDragCompleted(object sender, DragCompletedEventArgs args)
{
// it appears that the DragCompletedEventArgs.VerticalChange doesn't take DPI into account, so work around that.
double verticalChange = args.VerticalChange / dpiY;
```
Contributor guide
Assessment
This issue has not been assessed yet.