Skip to content

Commit

Permalink
Fix: TrackerControl is invisible on Windows platform
Browse files Browse the repository at this point in the history
  • Loading branch information
iniceice88 committed Sep 25, 2024
1 parent dd74210 commit 7d181ff
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Source/OxyPlot.Maui.Skia/PlotViewBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
9 changes: 7 additions & 2 deletions Source/OxyPlot.Maui.Skia/Tracker/TrackerControl.xaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentView x:Class="OxyPlot.Maui.Skia.TrackerControl" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<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">
<ContentView.Resources>
<ControlTemplate x:Key="TrackerControlTemplate">
<ControlTemplate x:Key="TrackerControlTemplate" x:DataType="skia:TrackerControl">
<AbsoluteLayout HorizontalOptions="Fill" VerticalOptions="Fill">
<Line
x:Name="PART_HorizontalLine"
Background="{TemplateBinding LineStroke}"
Fill="{TemplateBinding LineStroke}"
HeightRequest="1"
IsVisible="{TemplateBinding HorizontalLineVisibility}"
Stroke="{TemplateBinding LineStroke}"
StrokeDashArray="{TemplateBinding LineDashArray}"
WidthRequest="999" />
<Line
x:Name="PART_VerticalLine"
Background="{TemplateBinding LineStroke}"
Fill="{TemplateBinding LineStroke}"
HeightRequest="999"
IsVisible="{TemplateBinding VerticalLineVisibility}"
Stroke="{TemplateBinding LineStroke}"
Expand Down
26 changes: 6 additions & 20 deletions Source/OxyPlot.Maui.Skia/Tracker/TrackerControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -449,46 +449,32 @@ private void UpdatePositionAndBorder()

if (horizontalLine != null)
{
horizontalLine.WidthRequest = canvasWidth;

if (LineExtents.Width > 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;
Expand Down

0 comments on commit 7d181ff

Please sign in to comment.