Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

How can I create a custom renderer for a decorated "container" view with custom renderer?

$
0
0

I'm basically trying to create a custom "container" view, which will render differently on each platform, but its content will render the standard way. Specifically this would be like a menu item which contains complicated views, but the outter decoration remains the same in all cases. You cam imagine it something like this

example

but the container could contain any arbitrary Xamarin.Forms views, for example a layout with multiple views that would still render the normal way (or using their own custom renderers). The decoration would be the only thing that is platform specific.

How should I approach this? I could have a Content property on my container view, which would have the type View, and then somehow render that on each platform's renderer. But how do I take a View and render it in a platform specific way? A sample usage might be like this.

var foo = new Label { Text = "foo" };
var bar = new Label { Text = "bar" };

var box = new DecoratedBox { Content = new StackLayout { Children = { foo, bar } } };

Viewing all articles
Browse latest Browse all 58056

Trending Articles