summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSungHyun Min <shyun.min@samsung.com>2017-07-24 07:05:34 (GMT)
committerKangho Hur <kangho.hur@samsung.com>2017-10-23 04:34:39 (GMT)
commit2d3478a3f2deb0e30a90667ff8a71eae7285c002 (patch)
tree4430f7155a9d1eef03f461052a207a92ad352af2
parented6bf4e6fe2e34d7a149003021d2aacc83a9a95e (diff)
downloadxamarin-forms-2d3478a3f2deb0e30a90667ff8a71eae7285c002.zip
xamarin-forms-2d3478a3f2deb0e30a90667ff8a71eae7285c002.tar.gz
xamarin-forms-2d3478a3f2deb0e30a90667ff8a71eae7285c002.tar.bz2
Add DefaultRenderer
TASK=TCAPI-2601 - To prevent throwing exception when the renderer does not exist. e.g. using customized view that is inherited View without implementing Renderer. - To run ControlGallery app(Xamarin.Forms project) which uses View directly. Change-Id: I8244f24e2dec7cf6e54cddd0fb191a37c34c7936
-rw-r--r--Xamarin.Forms.Platform.Tizen/Platform.cs11
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/DefaultRenderer.cs18
2 files changed, 21 insertions, 8 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Platform.cs b/Xamarin.Forms.Platform.Tizen/Platform.cs
index c48a66e..5b0fd34 100644
--- a/Xamarin.Forms.Platform.Tizen/Platform.cs
+++ b/Xamarin.Forms.Platform.Tizen/Platform.cs
@@ -128,7 +128,7 @@ namespace Xamarin.Forms.Platform.Tizen
// Make naviitem transparent if Forms.Context.MainWindow is transparent.
// Make sure that this is only for _navModel._naviTree. (not for _navModel._modalStack)
// In addtion, the style of naviItem is only decided before the naviItem pushed into Naviframe. (not on-demand).
- if(Forms.Context.MainWindow.Alpha)
+ if (Forms.Context.MainWindow.Alpha)
{
naviItem.Style = "default/transparent";
}
@@ -172,12 +172,7 @@ namespace Xamarin.Forms.Platform.Tizen
static IVisualElementRenderer AttachRenderer(VisualElement view)
{
- IVisualElementRenderer visualElementRenderer = Registrar.Registered.GetHandler<IVisualElementRenderer>(view.GetType());
-
- if (null == visualElementRenderer)
- {
- throw new ArgumentException(String.Format("{0} doesn't have assigned renderer!", view.GetType()));
- }
+ IVisualElementRenderer visualElementRenderer = Registrar.Registered.GetHandler<IVisualElementRenderer>(view.GetType()) ?? new DefaultRenderer();
visualElementRenderer.SetElement(view);
@@ -344,4 +339,4 @@ namespace Xamarin.Forms.Platform.Tizen
tcs?.SetResult(true);
}
}
-}
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/DefaultRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/DefaultRenderer.cs
new file mode 100644
index 0000000..ab009ff
--- /dev/null
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/DefaultRenderer.cs
@@ -0,0 +1,18 @@
+using ElmSharp;
+using ELayout = ElmSharp.Layout;
+
+namespace Xamarin.Forms.Platform.Tizen
+{
+ public sealed class DefaultRenderer : VisualElementRenderer<VisualElement>
+ {
+ protected override void OnElementChanged(ElementChangedEventArgs<VisualElement> e)
+ {
+ if (NativeView == null)
+ {
+ var control = new ELayout(Forms.Context.MainWindow);
+ SetNativeControl(control);
+ }
+ base.OnElementChanged(e);
+ }
+ }
+} \ No newline at end of file