Skip to content

SP5 WinUi: automatic display scaling for pointer interaction #3642

@PZidlik

Description

@PZidlik

Suggestion:
I have a problem that scott plot is not reflecting the display scale in WinUi and in attachement should be path that should fix it.

// add this line to WinUiPlot() method in WinUIPlot.cs
        Loaded += WinUIPlot_Loaded;
//then created a handler for it this is called after initialization of the WinUiPlot to get proper display scale
    private void WinUIPlot_Loaded(object sender, RoutedEventArgs e)
    {
        if (XamlRoot != null)
        {
            XamlRoot.Changed += DetectDisplayScale; ;
            Plot.ScaleFactor = XamlRoot.RasterizationScale;
            DisplayScale = (float)XamlRoot.RasterizationScale;
        }
    }
// and also handler for detect display scale it is called when user move application from monitors with different scale
    private void DetectDisplayScale(XamlRoot sender, XamlRootChangedEventArgs args)
    {
        if (XamlRoot != null)
        {
            Plot.ScaleFactor = XamlRoot.RasterizationScale;
            DisplayScale = (float)XamlRoot.RasterizationScale;
        }
    }

ScottPlot-79f4062-SP5 WinUi automatic display scaling.patch

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions