title: Populate Observable collection from XML file in project (WPF)
body: <p>I Have XML file in my project</p>
  
  <p>Here is it</p>
  
  <pre><code>  &lt;?xml version="1.0"?&gt;
  &lt;catalog&gt;
     &lt;car id="1"&gt;
        &lt;model&gt;Scoda Fabia&lt;/model&gt;
        &lt;year&gt;2011&lt;/year&gt;
        &lt;producer&gt;Folkwagen&lt;/producer&gt;
        &lt;price&gt;6000&lt;/price&gt;
        &lt;owner&gt;Bil Johnson&lt;/owner&gt;
        &lt;tel&gt;+5810456455456&lt;/tel&gt;
        &lt;mileage&gt;670000&lt;/mileage&gt;
        &lt;registered&gt;USA&lt;/registered&gt;
        &lt;image&gt;Fabia1.JPG&lt;/image&gt;
     &lt;/car&gt;
     &lt;car id="2"&gt;
        &lt;model&gt;Huindai Getz&lt;/model&gt;
        &lt;year&gt;2008&lt;/year&gt;
        &lt;producer&gt;Huindai&lt;/producer&gt;
        &lt;price&gt;5000&lt;/price&gt;
        &lt;owner&gt;Dimitrious Gregorakis&lt;/owner&gt;
        &lt;tel&gt;+5810456445456&lt;/tel&gt;
        &lt;mileage&gt;120000&lt;/mileage&gt;
        &lt;registered&gt;USA&lt;/registered&gt;
        &lt;image&gt;hyundai_getz2.jpg&lt;/image&gt;
     &lt;/car&gt;
     &lt;car id="3"&gt;
        &lt;model&gt;Huindai i108&lt;/model&gt;
        &lt;year&gt;2014&lt;/year&gt;
        &lt;producer&gt;Huindai&lt;/producer&gt;
        &lt;price&gt;15000&lt;/price&gt;
        &lt;owner&gt;Dex Dexter&lt;/owner&gt;
        &lt;tel&gt;+5815556445456&lt;/tel&gt;
        &lt;mileage&gt;30000&lt;/mileage&gt;
        &lt;registered&gt;Canada&lt;/registered&gt;
        &lt;image&gt;hyundaii108.jpg&lt;/image&gt;
     &lt;/car&gt;
     &lt;car id="4"&gt;
        &lt;model&gt;Aveo&lt;/model&gt;
        &lt;year&gt;2000&lt;/year&gt;
        &lt;producer&gt;Shevrole&lt;/producer&gt;
        &lt;price&gt;3500&lt;/price&gt;
        &lt;owner&gt;Ivan Ivanov&lt;/owner&gt;
        &lt;tel&gt;+5815556445477&lt;/tel&gt;
        &lt;mileage&gt;300000&lt;/mileage&gt;
        &lt;registered&gt;Mexico&lt;/registered&gt;
        &lt;image&gt;aveo.jpg&lt;/image&gt;
     &lt;/car&gt;
  &lt;/catalog&gt;
  </code></pre>
  
  <p>I created a class from it, here is code for class</p>
  
  <pre><code> [XmlRoot(ElementName = "car")]
  public class Car
  {
      [XmlElement(ElementName = "model")]
      public string Model { get; set; }
      [XmlElement(ElementName = "year")]
      public string Year { get; set; }
      [XmlElement(ElementName = "producer")]
      public string Producer { get; set; }
      [XmlElement(ElementName = "price")]
      public string Price { get; set; }
      [XmlElement(ElementName = "owner")]
      public string Owner { get; set; }
      [XmlElement(ElementName = "tel")]
      public string Tel { get; set; }
      [XmlElement(ElementName = "mileage")]
      public string Mileage { get; set; }
      [XmlElement(ElementName = "registered")]
      public string Registered { get; set; }
      [XmlElement(ElementName = "image")]
      public string Image { get; set; }
      [XmlAttribute(AttributeName = "id")]
      public string Id { get; set; }
  }
  
  [XmlRoot(ElementName = "catalog")]
  public class Catalog
  {
      [XmlElement(ElementName = "car")]
      public List&lt;Car&gt; Car { get; set; }
  }
  </code></pre>
  
  <p>And Created ViewModel for it, where I defined observable collection anв define a method to fill it with data from XML</p>
  
  <pre><code>public class CarViewModel
  {
      public ObservableCollection&lt;List&lt;Car&gt;&gt; car { get; set; }
      public void LoadCars()
      {
          Car = new ObservableCollection&lt;List&lt;Car&gt;&gt;();
  
          var path = @"xml\CarsDatabase.xml";
          using (TextReader reader = new StreamReader(path))
          {
              XmlSerializer serializer = new XmlSerializer(typeof(Catalog));
              return (Catalog)serializer.Deserialize(reader);
          }
      }
  }
  </code></pre>
  
  <p>In method LoadCars I need to fill car observable collections with data in my file, that is inside of the project.</p>
  
  <p>How I can do this correctly?
  Thank's for help.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I try to use this method</p>
  
  <pre><code>public void LoadCars()
      {
          Car = new ObservableCollection&lt;List&lt;Car&gt;&gt;();
  
          var path = @"xml\CarsDatabase.xml";
          using (TextReader reader = new StreamReader(path))
          {
              XmlSerializer serializer = new XmlSerializer(typeof(Catalog));
              return (Catalog)serializer.Deserialize(reader);
          }
      }
  </code></pre>
  
  <p>But now I have error</p>
  
  <blockquote>
    <p>Severity  Code    Description Project File    Line    Suppression State
    Error   CS0127  Since 'CarViewModel.LoadCars()' returns void, a return keyword must not be followed by an object expression DaxxTest    C:\Users\nemes\Source\Repos\daxx_test\DaxxTest\DaxxTest\ViewModels\CarViewModel.cs  25  Active</p>
  </blockquote>