From 7d181ffef8692b4478bdcb423c7193132e925386 Mon Sep 17 00:00:00 2001 From: libin Date: Wed, 25 Sep 2024 16:02:58 +0800 Subject: [PATCH] Fix: TrackerControl is invisible on Windows platform --- Source/OxyPlot.Maui.Skia/PlotViewBase.cs | 2 +- .../Tracker/TrackerControl.xaml | 9 +++++-- .../Tracker/TrackerControl.xaml.cs | 26 +++++-------------- 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/Source/OxyPlot.Maui.Skia/PlotViewBase.cs b/Source/OxyPlot.Maui.Skia/PlotViewBase.cs index f105f6b..d3e1303 100644 --- a/Source/OxyPlot.Maui.Skia/PlotViewBase.cs +++ b/Source/OxyPlot.Maui.Skia/PlotViewBase.cs @@ -256,7 +256,7 @@ public void ShowTracker(TrackerHitResult trackerHitResult) var tracker = (ContentView)trackerTemplate.CreateContent(); this.overlays.Children.Add(tracker); - AbsoluteLayout.SetLayoutBounds(tracker, new Rect(0, 0, 0, 0)); + AbsoluteLayout.SetLayoutBounds(tracker, new Rect(0, 0, 1, 1)); this.currentTracker = tracker; this.currentTrackerTemplate = trackerTemplate; } diff --git a/Source/OxyPlot.Maui.Skia/Tracker/TrackerControl.xaml b/Source/OxyPlot.Maui.Skia/Tracker/TrackerControl.xaml index 32d1a29..b133f38 100644 --- a/Source/OxyPlot.Maui.Skia/Tracker/TrackerControl.xaml +++ b/Source/OxyPlot.Maui.Skia/Tracker/TrackerControl.xaml @@ -1,16 +1,21 @@  - + - + 0) { - horizontalLine.X1 = LineExtents.Left; - horizontalLine.X2 = LineExtents.Right; + horizontalLine.WidthRequest = LineExtents.Width; } else { - horizontalLine.X1 = 0; - horizontalLine.X2 = canvasWidth; + horizontalLine.WidthRequest = canvasWidth; } - horizontalLine.Y1 = Position.Y; - horizontalLine.Y2 = Position.Y; - horizontalLine.TranslationY = Position.Y; - horizontalLine.TranslationX = horizontalLine.X1; + horizontalLine.TranslationX = LineExtents.Left; } if (verticalLine != null) { - verticalLine.HeightRequest = canvasHeight; - if (LineExtents.Height > 0) { - verticalLine.Y1 = LineExtents.Top; - verticalLine.Y2 = LineExtents.Bottom; + verticalLine.HeightRequest = LineExtents.Height; } else { - verticalLine.Y1 = 0; - verticalLine.Y2 = canvasHeight; + verticalLine.HeightRequest = canvasHeight; } - verticalLine.X1 = Position.X; - verticalLine.X2 = Position.X; - verticalLine.TranslationX = Position.X; - verticalLine.TranslationY = verticalLine.Y1; + verticalLine.TranslationY = LineExtents.Top; } Opacity = 1;