title: Adding custom class with XAML in ListBox C# WPF
body: <p>I have a class <code>PC</code> that contains <code>Image</code>, <code>Label</code> (with <code>XAML</code> design) and I want to get a list of PCs in <code>ListBox</code> in other class.</p>
  
  <p>I tried this, but I get error <code>System.Windows.Markup.XamlParseException</code>:</p>
  
  <pre><code>pc p = new pc();
  list_pc.Items.Add(p);
  (where list_pc is a ListBox)
  </code></pre>
  
  <p>This is the <code>XAML</code> for a single <code>PC</code>:</p>
  
  <pre><code> &lt;Window
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
      x:Class="TnCyberCafe.pc"
      Title="pc"
      SizeToContent="WidthAndHeight"
      ShowInTaskbar="False"
      WindowStartupLocation="CenterScreen"
      WindowStyle="None"
      AllowsTransparency="True"
      Background="Transparent" Width="95" Height="104.982"&gt;
  
      &lt;Grid  HorizontalAlignment="Left" Margin="0,10,-15,10" Width="110"&gt;
          &lt;Image x:Name="image" HorizontalAlignment="Left" Height="96" VerticalAlignment="Top" Width="100" Source="Resources/aaa.png" RenderTransformOrigin="0.5,0.26" Margin="0,-16,0,0"/&gt;
          &lt;Label Content="Label" HorizontalAlignment="Left" Height="25" Margin="20,70,0,-10" VerticalAlignment="Top" Width="45"/&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>This is the <code>XAML</code> for my <code>list_pc</code>:</p>
  
  <pre><code>&lt;ListBox x:Name="liste_pc" ScrollViewer.VerticalScrollBarVisibility="Disabled"&gt;
      &lt;ListBox.ItemsPanel&gt;
          &lt;ItemsPanelTemplate&gt;
              &lt;WrapPanel IsItemsHost="True" Orientation="Horizontal"/&gt;
          &lt;/ItemsPanelTemplate&gt;
      &lt;/ListBox.ItemsPanel&gt;
      List PCs                
  &lt;/ListBox&gt;
  </code></pre>