title: Custom Label renderer not set binded text
body: <p>I have create a custom renderer for label that show the text in html format.</p>
  
  <p>This is the iOS's code:</p>
  
  <pre><code>   [assembly: ExportRenderer(typeof(LabelHtmlView), typeof(LabelHtmlCustomRenderer))]
  namespace SgatMobileV2.iOS {
      public class LabelHtmlCustomRenderer : LabelRenderer {              
  
          protected override void OnElementChanged(ElementChangedEventArgs&lt;Label&gt; e) {
              base.OnElementChanged(e);
  
              var View = (LabelHtmlView)Element;
              if (View == null) return;
  
              var Attribute = new NSAttributedStringDocumentAttributes();
              var NsError = new NSError();
  
              Attribute.DocumentType = NSDocumentType.HTML;
              View.Text = string.IsNullOrEmpty(View.Text) ? string.Empty : View.Text;
  
              Control.AttributedText = new NSAttributedString(View.Text, Attribute, ref NsError);
  
          }    
      }
  }
  </code></pre>
  
  <p>Android code:</p>
  
  <pre><code>[assembly: ExportRenderer(typeof(LabelHtmlView), typeof(LabelHtmlCustomRenderer))]
  namespace SgatMobileV2.Droid.CustomRenderer {
      public class LabelHtmlCustomRenderer : LabelRenderer {
  
          public LabelHtmlCustomRenderer(Context context)
              : base(context) {
          }
          protected override void OnElementChanged(ElementChangedEventArgs&lt;Label&gt; e) {
              base.OnElementChanged(e);
  
              var View = (LabelHtmlView)Element;
              if (View == null) return;
  
              Control.SetText(Html.FromHtml(View.Text.ToString(), FromHtmlOptions.ModeLegacy), TextView.BufferType.Spannable);
          }
  
      }
  }
  </code></pre>
  
  <p>I use, for example, the control in XAML in this way:</p>
  
  <pre><code>&lt;view:LabelHtmlView Text="{Binding WoDett.NotaTestata}" Grid.Row="0" Grid.Column="1" HeightRequest="200"/&gt;
  </code></pre>
  
  <p>where <code>WoDett</code> is a complex object and <code>NotaTestata</code> is a string that contains HTML markup.</p>
  
  <p>I have debugged the code and the <code>OnElementChanged</code> is called before I set the <code>WoDett</code> object, so the <code>NotaTestata</code> is <code>null</code>, so the label in XAML appears empty.</p>
  
  <p>This behavior is the same on iOS and Android.</p>
  
  <p>I have others custom renderer and they work properly with similar logic, but this label don't.</p>
  
  <p>How can I solve this?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>This is the <code>NotaTestata</code> property in the object class:</p>
  
  <pre><code>private string _NotaTestata = string.Empty;
  public string NotaTestata {
      get { return _NotaTestata; }
      set {
            _NotaTestata = value;
            OnPropertyChanged(nameof(NotaTestata));
          }
      }
  </code></pre>
  
  <p><strong>EDIT 2:</strong></p>
  
  <p>The same custom label inside a <code>ListView</code>, works fine.</p>
  
  <pre><code>&lt;ListView x:Name="ListaRigheWo" CachingStrategy="RetainElement" HasUnevenRows="True" SeparatorVisibility="Default" ItemsSource="{Binding ListaWORighe}"&gt;
  </code></pre>
  
  <p>where <code>ListaWORighe</code> is defined in this way:</p>
  
  <pre><code>public ObservableCollection&lt;WorkOrderDettaglioListaRighe&gt; ListaWORighe {
              get {
                  ObservableCollection&lt;WorkOrderDettaglioListaRighe&gt; Lista = null;
  
                  if (WoDett.ListaWORighe != null) {
                      Lista = OrdinamentoRigheWo(WoDett.ListaWORighe);
                  }
  
                  return Lista;
              }
              set {
                  WoDett.ListaWORighe = new List&lt;WorkOrderDettaglioListaRighe&gt;(value);
                  RaisePropertyChanged(() =&gt; ListaWORighe);
              }
          }
  </code></pre>
  
  <p>and the custom label is used like this:</p>
  
  <pre><code>&lt;view:LabelHtmlView Text="{Binding DescrizioneIntervento}" Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="4" Style="{StaticResource LblValore}" /&gt;
  </code></pre>
  
  <p><strong>EDIT 3:</strong></p>
  
  <p>Following the suggest of user @sme, I have modify the renderers like this, adding the override of OnElementPropertyChanged method:</p>
  
  <pre><code>protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) {
              base.OnElementPropertyChanged(sender, e);
              if (e.PropertyName == Label.TextProperty.PropertyName) {
                  UpdateText();
              }
          }
  
          protected override void OnElementChanged(ElementChangedEventArgs&lt;Label&gt; e) {
              base.OnElementChanged(e);
              UpdateText();
          }
  
          private void UpdateText() {
              var View = (LabelHtmlView)Element;
              if (View == null) return;
  
              var Attribute = new NSAttributedStringDocumentAttributes();
              var NsError = new NSError();
  
              Attribute.DocumentType = NSDocumentType.HTML;
              View.Text = string.IsNullOrEmpty(View.Text) ? string.Empty : View.Text;
  
              Control.AttributedText = new NSAttributedString(View.Text, Attribute, ref NsError);
          }
  </code></pre>