diff --git a/src/Uno.Toolkit.UI/Controls/ZoomContentControl/ZoomContentControl.Properties.cs b/src/Uno.Toolkit.UI/Controls/ZoomContentControl/ZoomContentControl.Properties.cs
index 1572a0e3f..59d7f6f51 100644
--- a/src/Uno.Toolkit.UI/Controls/ZoomContentControl/ZoomContentControl.Properties.cs
+++ b/src/Uno.Toolkit.UI/Controls/ZoomContentControl/ZoomContentControl.Properties.cs
@@ -276,7 +276,7 @@ public double MinZoomLevel
nameof(MaxZoomLevel),
typeof(double),
typeof(ZoomContentControl),
- new PropertyMetadata(500d, OnMaxZoomLevelChanged));
+ new PropertyMetadata(10d, OnMaxZoomLevelChanged));
/// Gets or sets the maximum zoom level allowed.
public double MaxZoomLevel
diff --git a/src/Uno.Toolkit.UI/Controls/ZoomContentControl/ZoomContentControl.cs b/src/Uno.Toolkit.UI/Controls/ZoomContentControl/ZoomContentControl.cs
index 58a3a4c5b..f67f086c8 100644
--- a/src/Uno.Toolkit.UI/Controls/ZoomContentControl/ZoomContentControl.cs
+++ b/src/Uno.Toolkit.UI/Controls/ZoomContentControl/ZoomContentControl.cs
@@ -39,6 +39,7 @@ namespace Uno.Toolkit.UI;
[TemplatePart(Name = TemplateParts.Presenter, Type = typeof(ContentPresenter))]
[TemplatePart(Name = TemplateParts.VerticalScrollBar, Type = typeof(ScrollBar))]
[TemplatePart(Name = TemplateParts.HorizontalScrollBar, Type = typeof(ScrollBar))]
+[TemplatePart(Name = TemplateParts.TranslateTransform, Type = typeof(TranslateTransform))]
public partial class ZoomContentControl : ContentControl
{
private static class TemplateParts
@@ -47,12 +48,16 @@ private static class TemplateParts
public const string Presenter = "PART_Presenter";
public const string HorizontalScrollBar = "PART_ScrollH";
public const string VerticalScrollBar = "PART_ScrollV";
+ public const string TranslateTransform = "PART_TranslateTransform";
}
- // Fields
+ // Template parts
private ContentPresenter? _presenter;
private ScrollBar? _scrollV;
private ScrollBar? _scrollH;
+ private TranslateTransform? _translateTransform;
+
+ // Fields
private Point _lastPosition = new Point(0, 0);
private (bool Horizontal, bool Vertical) _movementDirection = (false, false);
private bool IsAllowedToWork => (IsEnabled && IsActive && _presenter is not null);
@@ -98,6 +103,7 @@ private async void OnVerticalOffsetChanged()
{
UpdateContentBoundsVisibility();
UpdateScrollVisibility();
+ UpdateTranslation();
await RaiseRenderedContentUpdated();
}
@@ -216,12 +222,32 @@ T FindTemplatePart(string name) where T : class =>
_scrollV = FindTemplatePart(TemplateParts.VerticalScrollBar);
_scrollH = FindTemplatePart(TemplateParts.HorizontalScrollBar);
+ _translateTransform = FindTemplatePart("PART_TranslateTransform");
+
+ if (_scrollH != null)
+ {
+ _scrollH.Scroll += (sender, e) => UpdateTranslation();
+ }
+
+ if (_scrollV != null)
+ {
+ _scrollV.Scroll += (sender, e) => UpdateTranslation();
+ }
+
ResetOffset();
ResetZoom();
-
RegisterToControlEvents();
}
+ private void UpdateTranslation()
+ {
+ if (_translateTransform != null && _scrollH != null && _scrollV != null)
+ {
+ _translateTransform.X = -_scrollH.Value;
+ _translateTransform.Y = _scrollV.Value;
+ }
+ }
+
// Event handlers
private void OnLoaded(object sender, RoutedEventArgs e)
{
diff --git a/src/Uno.Toolkit.UI/Controls/ZoomContentControl/ZoomContentControl.xaml b/src/Uno.Toolkit.UI/Controls/ZoomContentControl/ZoomContentControl.xaml
index 9280a281b..a6d1f9132 100644
--- a/src/Uno.Toolkit.UI/Controls/ZoomContentControl/ZoomContentControl.xaml
+++ b/src/Uno.Toolkit.UI/Controls/ZoomContentControl/ZoomContentControl.xaml
@@ -38,8 +38,7 @@
CenterY="{TemplateBinding VerticalZoomCenter}"
ScaleX="{TemplateBinding ZoomLevel}"
ScaleY="{TemplateBinding ZoomLevel}" />
-
+
@@ -58,7 +57,7 @@
SmallChange="1"
Visibility="{TemplateBinding IsVerticalScrollBarVisible}"
ViewportSize="{TemplateBinding ViewportHeight}"
- Value="{TemplateBinding VerticalOffset}" />
+ Value="{TemplateBinding VerticalScrollValue}" />