title: How to get the name of Xamarin.Forms element from object?
body: <p>Views like <code>Button</code>, <code>Entry</code>, <code>Label</code>, <code>Picker</code> and so on can have a <code>x:Name</code> attribute.</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;Label x:Name="myLabelName" Text="Some text" /&gt;
  </code></pre>
  
  <p><code>x</code> is defined as <code>xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"</code>.</p>
  
  <p>Now I want to work with unclassified items and therefore I use <code>object</code> as type.</p>
  
  <p>How do I get the <code>x:Name</code> attribute as string in code from a <code>object</code>? I don't know the type at this stage.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>To make things more clear I want to post some code. I have a normal XAML page like this:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
               xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
               x:Class="XamlSamples.HelloXamlPage"&gt;
      &lt;Label x:Name="myLabelName" Text="Some text" /&gt;
  &lt;/ContentPage&gt;
  </code></pre>
  
  <p>In the code-behind file I can get the <code>x:Name</code> attribute if I do <code>nameof(this.myLabelName)</code>. But how is this done if you have <code>object</code> only?</p>
  
  <pre class="lang-cs prettyprint-override"><code>public partial class HelloXamlPage
  {
      public HelloXamlPage()
      {
          InitializeComponent();
  
          List&lt;string&gt; itemsWhichPassTheCheck = this.Check(new List&lt;object&gt;() { this.myLabelName });
      }
  }
  
  private List&lt;string&gt; Check(List&lt;object&gt; itemList)
  {
      // do some check here ...
      // here I have only object and I want to get the x:Name attribute thereof
  }
  </code></pre>