Skip to content

Commit ad98df7

Browse files
authored
Merge pull request #16 from iniceice88/fix/tracker
Fix: TrackerControl is invisible on Windows platform
2 parents f5c875b + 7d181ff commit ad98df7

File tree

3 files changed

+14
-23
lines changed

3 files changed

+14
-23
lines changed

Source/OxyPlot.Maui.Skia/PlotViewBase.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ public void ShowTracker(TrackerHitResult trackerHitResult)
256256

257257
var tracker = (ContentView)trackerTemplate.CreateContent();
258258
this.overlays.Children.Add(tracker);
259-
AbsoluteLayout.SetLayoutBounds(tracker, new Rect(0, 0, 0, 0));
259+
AbsoluteLayout.SetLayoutBounds(tracker, new Rect(0, 0, 1, 1));
260260
this.currentTracker = tracker;
261261
this.currentTrackerTemplate = trackerTemplate;
262262
}

Source/OxyPlot.Maui.Skia/Tracker/TrackerControl.xaml

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
<?xml version="1.0" encoding="utf-8" ?>
2-
<ContentView x:Class="OxyPlot.Maui.Skia.TrackerControl" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
2+
<ContentView x:Class="OxyPlot.Maui.Skia.TrackerControl" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:skia="using:OxyPlot.Maui.Skia">
33
<ContentView.Resources>
4-
<ControlTemplate x:Key="TrackerControlTemplate">
4+
<ControlTemplate x:Key="TrackerControlTemplate" x:DataType="skia:TrackerControl">
55
<AbsoluteLayout HorizontalOptions="Fill" VerticalOptions="Fill">
66
<Line
77
x:Name="PART_HorizontalLine"
8+
Background="{TemplateBinding LineStroke}"
9+
Fill="{TemplateBinding LineStroke}"
810
HeightRequest="1"
911
IsVisible="{TemplateBinding HorizontalLineVisibility}"
1012
Stroke="{TemplateBinding LineStroke}"
13+
StrokeDashArray="{TemplateBinding LineDashArray}"
1114
WidthRequest="999" />
1215
<Line
1316
x:Name="PART_VerticalLine"
17+
Background="{TemplateBinding LineStroke}"
18+
Fill="{TemplateBinding LineStroke}"
1419
HeightRequest="999"
1520
IsVisible="{TemplateBinding VerticalLineVisibility}"
1621
Stroke="{TemplateBinding LineStroke}"

Source/OxyPlot.Maui.Skia/Tracker/TrackerControl.xaml.cs

+6-20
Original file line numberDiff line numberDiff line change
@@ -449,46 +449,32 @@ private void UpdatePositionAndBorder()
449449

450450
if (horizontalLine != null)
451451
{
452-
horizontalLine.WidthRequest = canvasWidth;
453-
454452
if (LineExtents.Width > 0)
455453
{
456-
horizontalLine.X1 = LineExtents.Left;
457-
horizontalLine.X2 = LineExtents.Right;
454+
horizontalLine.WidthRequest = LineExtents.Width;
458455
}
459456
else
460457
{
461-
horizontalLine.X1 = 0;
462-
horizontalLine.X2 = canvasWidth;
458+
horizontalLine.WidthRequest = canvasWidth;
463459
}
464460

465-
horizontalLine.Y1 = Position.Y;
466-
horizontalLine.Y2 = Position.Y;
467-
468461
horizontalLine.TranslationY = Position.Y;
469-
horizontalLine.TranslationX = horizontalLine.X1;
462+
horizontalLine.TranslationX = LineExtents.Left;
470463
}
471464

472465
if (verticalLine != null)
473466
{
474-
verticalLine.HeightRequest = canvasHeight;
475-
476467
if (LineExtents.Height > 0)
477468
{
478-
verticalLine.Y1 = LineExtents.Top;
479-
verticalLine.Y2 = LineExtents.Bottom;
469+
verticalLine.HeightRequest = LineExtents.Height;
480470
}
481471
else
482472
{
483-
verticalLine.Y1 = 0;
484-
verticalLine.Y2 = canvasHeight;
473+
verticalLine.HeightRequest = canvasHeight;
485474
}
486475

487-
verticalLine.X1 = Position.X;
488-
verticalLine.X2 = Position.X;
489-
490476
verticalLine.TranslationX = Position.X;
491-
verticalLine.TranslationY = verticalLine.Y1;
477+
verticalLine.TranslationY = LineExtents.Top;
492478
}
493479

494480
Opacity = 1;

0 commit comments

Comments
 (0)