summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.ControlGallery.WindowsUniversal
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2017-06-20 09:38:58 -0600
committerRui Marinho <me@ruimarinho.net>2017-06-20 16:38:58 +0100
commitf7c943dc7798b3449d2bf8319aca8a9ab448ffec (patch)
tree7b27d6245816765fb320e130d2995f06a1ec3d78 /Xamarin.Forms.ControlGallery.WindowsUniversal
parentc0a55911ac66caff70dfbefb83a3dcb69c991025 (diff)
downloadxamarin-forms-f7c943dc7798b3449d2bf8319aca8a9ab448ffec.tar.gz
xamarin-forms-f7c943dc7798b3449d2bf8319aca8a9ab448ffec.tar.bz2
xamarin-forms-f7c943dc7798b3449d2bf8319aca8a9ab448ffec.zip
[iOS] Allow Forms gestures on custom renderers for controls which already have gestures (#990)
* Repro 57114 with UI test; fix for 57114 on iOS * Repro/UI test for Windows * Add helpful comment for posterity * Remove stray TODO * Only do ShouldReceiveTouch on mobile * Explicitly require wrapped UIView to have gesture recognizers
Diffstat (limited to 'Xamarin.Forms.ControlGallery.WindowsUniversal')
-rw-r--r--Xamarin.Forms.ControlGallery.WindowsUniversal/Xamarin.Forms.ControlGallery.WindowsUniversal.csproj1
-rw-r--r--Xamarin.Forms.ControlGallery.WindowsUniversal/_57114Renderer.cs48
2 files changed, 49 insertions, 0 deletions
diff --git a/Xamarin.Forms.ControlGallery.WindowsUniversal/Xamarin.Forms.ControlGallery.WindowsUniversal.csproj b/Xamarin.Forms.ControlGallery.WindowsUniversal/Xamarin.Forms.ControlGallery.WindowsUniversal.csproj
index 323d2fd8..666cbe76 100644
--- a/Xamarin.Forms.ControlGallery.WindowsUniversal/Xamarin.Forms.ControlGallery.WindowsUniversal.csproj
+++ b/Xamarin.Forms.ControlGallery.WindowsUniversal/Xamarin.Forms.ControlGallery.WindowsUniversal.csproj
@@ -120,6 +120,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
+ <Compile Include="_57114Renderer.cs" />
<Content Include="coffee.png" />
<Content Include="default.css" />
<Content Include="invalidimage.jpg" />
diff --git a/Xamarin.Forms.ControlGallery.WindowsUniversal/_57114Renderer.cs b/Xamarin.Forms.ControlGallery.WindowsUniversal/_57114Renderer.cs
new file mode 100644
index 00000000..94032094
--- /dev/null
+++ b/Xamarin.Forms.ControlGallery.WindowsUniversal/_57114Renderer.cs
@@ -0,0 +1,48 @@
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Xamarin.Forms.ControlGallery.WindowsUniversal;
+using Xamarin.Forms.Controls.Issues;
+using Xamarin.Forms.Platform.UWP;
+
+[assembly: ExportRenderer(typeof(Bugzilla57114._57114View), typeof(_57114Renderer))]
+
+namespace Xamarin.Forms.ControlGallery.WindowsUniversal
+{
+ public class _57114Renderer : VisualElementRenderer<Bugzilla57114._57114View, _57114NativeView>
+ {
+ protected override void OnElementChanged(ElementChangedEventArgs<Bugzilla57114._57114View> e)
+ {
+ if (e.NewElement != null && Control == null)
+ {
+ var view = new _57114NativeView();
+ SetNativeControl(view);
+
+ }
+
+ base.OnElementChanged(e);
+
+ if (Control != null)
+ {
+ Control.Background = ColorToBrush(Element.BackgroundColor);
+ }
+ }
+
+ Brush ColorToBrush(Color color)
+ {
+ return new SolidColorBrush(Windows.UI.Color.FromArgb((byte)(color.A * 255), (byte)(color.R * 255), (byte)(color.G * 255), (byte)(color.B * 255)));
+ }
+ }
+
+ public class _57114NativeView : Windows.UI.Xaml.Controls.Grid
+ {
+ public _57114NativeView()
+ {
+ Tapped += OnTapped;
+ }
+
+ void OnTapped(object sender, TappedRoutedEventArgs tappedRoutedEventArgs)
+ {
+ MessagingCenter.Send(this as object, Bugzilla57114._57114NativeGestureFiredMessage);
+ }
+ }
+} \ No newline at end of file