title: Binding to a structure
body: <p>I am trying to bind a listview item to a member of a structure, but I am unable to get it to work.</p>
  
  <p>The structure is quite simple:</p>
  
  <pre><code>public struct DeviceTypeInfo
  {
      public String deviceName;
      public int deviceReferenceID;
  };
  </code></pre>
  
  <p>in my view model I hold a list of these structures and I want to get the "deviceName" to be displayed in a list box.</p>
  
  <pre><code>public class DevicesListViewModel
  {
      public DevicesListViewModel( )
      {
  
      }
  
      public void setListOfAvailableDevices(List&lt;DeviceTypeInfo&gt; devicesList)
      {
          m_availableDevices = devicesList;
      }
  
      public List&lt;DeviceTypeInfo&gt; Devices
      {
          get { return m_availableDevices; }
      }
  
      private List&lt;DeviceTypeInfo&gt; m_availableDevices;
  }
  </code></pre>
  
  <p>I have tried the following but I can't get the binding to work, do I need to use relativesource?</p>
  
  <pre><code>    &lt;ListBox Name="DevicesListView" Grid.Column="0" VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="10"  MinHeight="250" MinWidth="150"  ItemsSource="{Binding Devices}" Width="Auto"&gt;
          &lt;ListBox.ItemTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;StackPanel Orientation="Vertical"&gt;
                      &lt;TextBlock Text="{Binding DeviceTypeInfo.deviceName}"/&gt;
                  &lt;/StackPanel&gt;
              &lt;/DataTemplate&gt;
          &lt;/ListBox.ItemTemplate&gt;
      &lt;/ListBox&gt;
  </code></pre>