title: How to set ItemsSource of ListView?
body: <p>Here I have defined my data <em>myListOfEmployeeObjects</em>:</p>
  
  <pre><code>public class App : Application
  {
      public List&lt;Employee&gt; myListOfEmployeeObjects;
  
      public App ()
      {
          Employee emp1 = new Employee () {
              FirstName = "Max",
              LastName = "Mustermann",
              Twitter = "@fake1"
          };
          Employee emp2 = new Employee () {
              FirstName = "Evy",
              LastName = "Mustermann",
              Twitter = "@fake2"
          };
          myListOfEmployeeObjects = new List&lt;Employee&gt; {
              emp1, emp2
          };
          MainPage = new NavigationPage (new EmployeeListPage ());
      }
  }
  </code></pre>
  
  <p>Than I have my XAML where I set the <code>ItemsSource</code>:</p>
  
  <pre><code>&lt;ListView x:Name="listView"
                  IsVisible="false"
                  ItemsSource="{x:Static local:App.myListOfEmployeeObjects}"
                  ItemSelected="EmployeeListOnItemSelected"&gt;
  </code></pre>
  
  <p>Should this work? Because I get</p>
  
  <blockquote>
    <p>Xamarin.Forms.Xaml.XamlParseException: Type App not found in xmlns</p>
  </blockquote>
  
  <pre><code>public partial class EmployeeListPage : ContentPage {
  
      private ListView listView;
  
      private void InitializeComponent() {
          this.LoadFromXaml(typeof(EmployeeListPage)); // here the exception is thrown
          listView = this.FindByName &lt;ListView&gt;("listView");
      }
  }
  </code></pre>
  
  <p>How can I set the <code>ItemsSource</code> of my XAML?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Now I tried the suggestion from <a href="https://stackoverflow.com/users/2425632/user2425632"><em>user2425632</em></a> and it works if I do the following changes:</p>
  
  <ol>
  <li>Adding <code>xmlns:local="clr-namespace:HelloXamarinFormsWorld;assembly=HelloXamarinFormsWorld"</code> to my XAML file</li>
  </ol>
  
  <p>It now looks like the following</p>
  
  <pre><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"
               xmlns:local="clr-namespace:HelloXamarinFormsWorld;assembly=HelloXamarinFormsWorld"
               x:Class="HelloXamarinFormsWorld.EmployeeListPage"
               Title="Employee List"&gt;
      &lt;ContentPage.Content&gt;
  </code></pre>
  
  <p>Of course you have to change the names so that it suits to your project.</p>
  
  <ol start="2">
  <li>Showing list view</li>
  </ol>
  
  <p>I removed the <code>IsVisible</code> and the <code>ItemSelected</code>.</p>
  
  <pre><code>&lt;ListView ItemsSource="{x:Static local:App.myListOfEmployeeObjects}"&gt;
  </code></pre>
  
  <ol start="3">
  <li>Make everything static</li>
  </ol>
  
  <p>It has to be static, otherwise you get</p>
  
  <blockquote>
    <p>No static member found for local:App.myListOfEmployeeObjects</p>
  </blockquote>
  
  <pre><code>public static List&lt;Employee&gt; myListOfEmployeeObjects { private set; get; }
  
  public static void GetAllEmployees(){
      Employee emp1 = new Employee () {
          FirstName = "Max",
          LastName = "Mustermann",
          Twitter = "@fake1"
      };
      Employee emp2 = new Employee () {
          FirstName = "Eva",
          LastName = "Mustermann",
          Twitter = "@fake2"
      };
      myListOfEmployeeObjects = new List&lt;Employee&gt; {
          emp1, emp2
      };
  }
  
  public App ()
  {
      GetAllEmployees ();
      MainPage = new NavigationPage (new EmployeeListPage ());
  }
  </code></pre>