title: No property, bindable property, or event found for 'MaxLength', or mismatching type between value and property
body: <p>Since Xamarin 2.4 (and switch to .Net Standard instead of PCL) I get the following error by using my own behaviour (XAMLC is :</p>
  
  <pre><code>No property, bindable property, or event found for 'MaxLength', or mismatching type between value and property.
  </code></pre>
  
  <p>Here is the implementation (very simple):</p>
  
  <pre><code>using Xamarin.Forms;
  
  namespace com.rsag.xflib.Behaviors
  {
      /// &lt;summary&gt;
      ///     Constrain the number of charachters on entry to the given length
      /// &lt;/summary&gt;
      public class MaxLengthEntryBehavior : Behavior&lt;Entry&gt;
      {
          /// &lt;summary&gt;
          ///     Value to prevent constraint
          /// &lt;/summary&gt;
          public const int NOT_CONSTRAINED = 0;
  
          /// &lt;summary&gt;
          ///     Bindable property for &lt;see cref="MaxLength" /&gt;
          /// &lt;/summary&gt;
          public static readonly BindableProperty MaxLengthProperty = BindableProperty.Create(nameof(MaxLength),
              typeof(int), typeof(MaxLengthEntryBehavior), NOT_CONSTRAINED, validateValue: ValidateMaxValue);
  
          /// &lt;summary&gt;
          ///     Max. length for the text (-1: not constrained)
          /// &lt;/summary&gt;
          public int MaxLength
          {
              get =&gt; (int) GetValue(MaxLengthProperty);
              set =&gt; SetValue(MaxLengthProperty, value);
          }
  
          private static bool ValidateMaxValue(BindableObject bindable, object value)
          {
              if (value is int intValue)
              {
                  return intValue &gt;= NOT_CONSTRAINED;
              }
  
              return false;
          }
  
          /// &lt;inheritdoc /&gt;
          protected override void OnAttachedTo(Entry bindable)
          {
              if (bindable != null)
              {
                  bindable.TextChanged += OnTextChanged;
              }
          }
  
          /// &lt;inheritdoc /&gt;
          protected override void OnDetachingFrom(Entry bindable)
          {
              if (bindable != null)
              {
                  bindable.TextChanged -= OnTextChanged;
              }
          }
  
          private void OnTextChanged(object sender, TextChangedEventArgs e)
          {
              if (MaxLength == NOT_CONSTRAINED)
              {
                  return;
              }
  
              if (string.IsNullOrEmpty(e.NewTextValue))
              {
                  return;
              }
  
              var entry = (Entry) sender;
  
              if (e.NewTextValue.Length &gt; MaxLength)
              {
                  entry.Text = e.NewTextValue.Substring(0, MaxLength);
              }
          }
      }
  }
  </code></pre>
  
  <p>The usage in the App is also very simple:</p>
  
  <pre><code>&lt;Entry Text="{Binding ServerPort.Value Keyboard="Numeric"&gt;
      &lt;Entry.Behaviors&gt;
          &lt;libBehav:MaxLengthEntryBehavior MaxLength="{x:Static ac:Constants.MAX_PORT_LENGTH}" /&gt;
      &lt;/Entry.Behaviors&gt;
  &lt;/Entry&gt;
  </code></pre>
  
  <p>This compilation works with a literal <code>MaxLength="10"</code> and with Bindings <code>MaxLength="{StaticResource MyValue}"</code> but not with a value from a static class. I need the value in XAML and in some C# code, so I would like to use the <code>Constants</code> class.</p>
  
  <p>The value in a static class is defined as follows:</p>
  
  <pre><code>public const int MAX_PORT_LENGTH = 5;
  </code></pre>
  
  <p><strong>Edit 2018-01-09</strong></p>
  
  <p>The problems seems to be in the use of inner classes. The following works:</p>
  
  <pre><code>MaxLength="{x:Static ac:Constants.MAX_PORT_LENGTH}"
  </code></pre>
  
  <p>But not this:</p>
  
  <pre><code>MaxLength="{x:Static ac:Constants.ServerConstraints.MAX_PORT_LENGTH}"
  </code></pre>