I want to customize the Label control to do some formatting of the text. I can write the C# code to do something, but am having trouble getting it to compile with the custom label in the xaml.
Here's what I have:
xmlns:custom="clr-namespace:myAssociation;assembly=myAssociation"
Then when I try to use it I have:
<custom:CustomLabel x:Name="lblUsername"
My class is:
using System;
using System.ComponentModel;
using Xamarin.Forms;
namespace myAssociation
{
public class CustomLabel : Label
{
public CustomLabel ()
{
}
}
}
And my renderer:
using System;
using System.Drawing;
using Foundation;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
using myAssociation;
using myAssociation.iOS;
[assembly:ExportRenderer (typeof(CustomLabel), typeof(CustomRenderer))]
namespace myAssociation.iOS
{
public class CustomRenderer : LabelRenderer
{
protected override void OnElementChanged (ElementChangedEventArgs<Label> e)
{
base.OnElementChanged (e);
// my code
}
}
}
When I attempt to compile I get the error:
The type or namespace name
CustomLabel' does not exist in the namespace CaliforniaMedicalAssociation'. Are you missing an assembly reference? (CS0234) (myAssociation.iOS)
I can't find documentation on how to include a custom control in xaml nor can I figure out why how to get around this error!
Thanks in advance!