Reset transformation properly on UWP (#7385) (#7386)
authorPhilippe Leybaert <philippe@activa.be>
Mon, 11 Nov 2019 18:50:53 +0000 (12:50 -0600)
committerSamantha Houts <samhouts@users.noreply.github.com>
Mon, 11 Nov 2019 18:50:53 +0000 (10:50 -0800)
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7385.cs [new file with mode: 0644]
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
Xamarin.Forms.Platform.UAP/VisualElementTracker.cs

diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7385.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7385.cs
new file mode 100644 (file)
index 0000000..04cfae3
--- /dev/null
@@ -0,0 +1,39 @@
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+namespace Xamarin.Forms.Controls.Issues
+{
+       [Preserve(AllMembers = true)]
+       [Issue(IssueTracker.Github, 7385, "[Bug] [UWP] Resetting Translation/Rotation does nothing", PlatformAffected.UWP)]
+       public class Issue7385 : TestContentPage
+       {
+               View _box;
+
+               protected override void Init()
+               {
+                       _box = new BoxView
+                       {
+                               WidthRequest = 50,
+                               HeightRequest = 50,
+                               HorizontalOptions = LayoutOptions.Start,
+                               VerticalOptions = LayoutOptions.Start,
+                               BackgroundColor = Color.Red
+                       };
+
+                       var button1 = new Button { Text = "Set TranslationX/Y to 30,20", Command = new Command(() => MoveBox(30, 20)) };
+                       var button2 = new Button { Text = "Set TranslationX to 0", Command = new Command(() => MoveBox(x: 0)) };
+                       var button3 = new Button { Text = "Set TranslationY to 0", Command = new Command(() => MoveBox(y: 0)) };
+
+                       Content = new StackLayout { Children = { new StackLayout { HeightRequest = 200, Children = { _box } }, new StackLayout { Orientation = StackOrientation.Horizontal, Children = { button1, button2, button3 } } } };
+               }
+
+               private void MoveBox(double? x = null, double? y = null)
+               {
+                       if (x != null)
+                               _box.TranslationX = x.Value;
+
+                       if (y != null)
+                               _box.TranslationY = y.Value;
+               }
+       }
+}
\ No newline at end of file
index a4f90ff..cb39b75 100644 (file)
@@ -63,6 +63,7 @@
     </Compile>
     <Compile Include="$(MSBuildThisFileDirectory)Issue7049.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Issue7061.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)Issue7385.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Issue7111.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Issue7357.xaml.cs">
       <SubType>Code</SubType>
index 368ee4a..e380e35 100644 (file)
@@ -533,6 +533,7 @@ namespace Xamarin.Forms.Platform.UWP
                        if (rotationX % 360 == 0 && rotationY % 360 == 0 && rotation % 360 == 0 && translationX == 0 && translationY == 0 && scaleX == 1 && scaleY == 1)
                        {
                                frameworkElement.Projection = null;
+                               frameworkElement.RenderTransform = null;
                        }
                        else
                        {