Skip to content

Instantly share code, notes, and snippets.

@rmarinho
Last active January 27, 2016 20:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmarinho/79933e7981d5b80e9a47 to your computer and use it in GitHub Desktop.
Save rmarinho/79933e7981d5b80e9a47 to your computer and use it in GitHub Desktop.
public class DummyPanel : Canvas
{
ContentControl control;
VisualElement element;
public DummyPanel(VisualElement element)
{
this.element = element;
DispatchAdd();
}
void AddControl()
{
if (control != null)
{
Children.Remove(control);
}
Width = 200;
Height = 200;
control = new ContentControl();
control.Content = "UWPApplication";
SetLeft (control, 200);
SetTop (control, 200);
Children.Add(control);
control.InvalidateMeasure();
control.InvalidateArrange();
((IVisualElementController)this.element).NativeSizeChanged ();
}
internal IAsyncAction renderSeriesAction;
void DispatchAdd()
{
if (renderSeriesAction == null)
renderSeriesAction = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, AddControl);
}
}
[assembly: ExportRenderer(typeof(Xamarin.Forms.Label), typeof(App2.UWP.LabelRenderer))]
namespace App2.UWP
{
public class LabelRenderer : ViewRenderer<Xamarin.Forms.Label, DummyPanel>
{
DummyPanel panel;
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Label> e)
{
base.OnElementChanged(e);
panel = new DummyPanel (e.NewElement);
SetNativeControl(panel);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment