There are some good examples of how to create a ācustom controlā with
I want to create an āOR usercontrol composite user controlā that contains several elements that are defined in XAML (in common code) and then configured using a visualization tool (to say, on the platform).
Does anyone have an example of this? A simple presentation example that has a label and an input field should be sufficient to show the basic principles.
Here is what I still have -
Defined by ContentView to represent our layout and our userās content.
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="News.Forms.VisualNewsContentView"> <ContentView.Content> <StackLayout> <Label x:Name="MyLabel" Text="Label"></Label> <Entry x:Name="MyEntry" Text="Entry"></Entry> </StackLayout> </ContentView.Content> </ContentView>
with codebehind -
public partial class VisualNewsContentView : ContentView { public VisualNewsContentView () { InitializeComponent (); }
Add Android custom rendering for this ContentView, how do I access and customize my own parts / controls for ContentView?
[assembly:ExportRenderer (typeof(VisualNewsContentView), typeof(VisualNewsRenderer))] namespace News.Forms.Android { public class VisualNewsRenderer: ViewRenderer { public VisualNewsRenderer () { } protected override void OnModelChanged (VisualElement oldModel, VisualElement newModel) { base.OnModelChanged (oldModel, newModel); if (newModel != null) { VisualNewsContentView newsContentView = newModel as VisualNewsContentView;
Itās just not possible to put everything together, the ContentView seems to be working fine on the page, but cannot decide how to access its Child Native elements in the viewrenderer.
It is also nice to show how you can use binding for label values āāand text input.
I do not want to define a custom renderer for each individual label / record, etc. usercontrol.