title: Binding ItemsControl to ScrollViewer
body: <p>At the begining I'll show some code:</p>
  
  <pre><code>private ObservableCollection&lt;otwarteBezStolika&gt; otwarteBezStolika = new ObservableCollection&lt;otwarteBezStolika&gt;();
  
          public ObservableCollection&lt;otwarteBezStolika&gt; listunia
          {
              get { return otwarteBezStolika; }
              set { otwarteBezStolika = value; }
          }
      }
      public class otwarteBezStolika
      {
          public string number { get; set; }
          public string date { get; set; }
          public int orderID { get; set; }
          public decimal price { get; set; }
          public decimal priceR { get; set; }
          public string opisRach { get; set; }
          public string sum { get; set; }
      }
  </code></pre>
  
  <p>And now in xaml:</p>
  
  <pre><code>&lt;Window.Resources&gt;
      &lt;DataTemplate x:Key="dataTempl"&gt;
          &lt;Border BorderBrush="Coral" BorderThickness="1" Width="170"&gt;
              &lt;Button Name="goToPOS" Tag="{Binding orderID}" Click="goToPOS_Click" Style="{StaticResource TabCloseButtonStyle}" Margin="1"&gt;
                  &lt;StackPanel&gt;
                      &lt;Label Content="{Binding number}" HorizontalAlignment="Center" FontSize="15" FontWeight="ExtraBold" HorizontalContentAlignment="Center"&gt;&lt;/Label&gt;
                      &lt;Border BorderBrush="Turquoise" BorderThickness="1" Width="170"&gt;&lt;/Border&gt;
                      &lt;Label Content="{Binding date}" FontSize="12" HorizontalAlignment="Center"&gt;&lt;/Label&gt;
                      &lt;TextBlock Text="{Binding opisRach}" FontStyle="Italic" FontSize="12" Foreground="Black" TextAlignment="Center" TextWrapping="Wrap" Margin="0,0,0,2"&gt;&lt;/TextBlock&gt;
                      &lt;Border BorderBrush="WhiteSmoke" BorderThickness="1" Width="170"&gt;&lt;/Border&gt;
                      &lt;Label Content="{Binding sum}" FontSize="19" HorizontalAlignment="Center"&gt;&lt;/Label&gt;
                  &lt;/StackPanel&gt;
              &lt;/Button&gt;
          &lt;/Border&gt;
      &lt;/DataTemplate&gt;
  
      &lt;DataTemplate x:Key="mainTemplate"&gt;
          &lt;StackPanel&gt;
  
              &lt;ItemsControl x:Name="imageContent" ItemsSource="{Binding listunia}" ItemTemplate="{StaticResource dataTempl}" &gt;
                  &lt;ItemsControl.ItemsPanel&gt;
                      &lt;ItemsPanelTemplate&gt;
                          &lt;WrapPanel Orientation="Horizontal" ScrollViewer.HorizontalScrollBarVisibility="Disabled" /&gt;
                      &lt;/ItemsPanelTemplate&gt;
                  &lt;/ItemsControl.ItemsPanel&gt;
              &lt;/ItemsControl&gt;
          &lt;/StackPanel&gt;
      &lt;/DataTemplate&gt;
  &lt;/Window.Resources&gt;
  </code></pre>
  
  <p>Grid:</p>
  
  <pre><code>&lt;Grid Grid.Row="0"&gt;
          &lt;ScrollViewer VerticalScrollBarVisibility="Auto"&gt;
              &lt;ItemsControl Name="templ" ItemsSource="{Binding ElementName=UI, Path=listunia }" ItemTemplate="{StaticResource mainTemplate}" /&gt;
          &lt;/ScrollViewer&gt;
      &lt;/Grid&gt;
  </code></pre>
  
  <p>Problem is that I cannot see any item (I'm filling items using sqldatareader, and adding them to list - by the way, does DataTable will also work? So instead while(rdr.Read()) i could ouse SqlDataAdapter sda and sda.fill(Datatable))</p>
  
  <p>Second problem is that, it does work when I put "dataTempl" inside scrollviewer ,like :</p>
  
  <pre><code>&lt;Grid Grid.Row="0"&gt;
          &lt;ScrollViewer VerticalScrollBarVisibility="Auto"&gt;
              &lt;ItemsControl Name="templ" ItemsSource="{Binding ElementName=UI, Path=listunia }" ItemTemplate="{StaticResource dataTempl}" /&gt;
          &lt;/ScrollViewer&gt;
      &lt;/Grid&gt;
  </code></pre>
  
  <p>but items are show vertically, but I need to see them from left to right horizontal.</p>
  
  <p>Thanks for answers!</p>