title: Silverlight - Style ScrollViewer for Listbox
body: <p>so i have been trying to style a scrollviewer, so that i can change the appearance of a scroll bar. But the problem I am facing, is that when I apply the scrollviewer style to the ListBox, I never see the content anymore. </p>
  
  <p>This is the current style I have: (Unchanged from the default at the moment)</p>
  
  <pre><code>&lt;Style x:Key="CustomScrollViewerStyle" TargetType="ScrollViewer"&gt;
      &lt;Setter Property="HorizontalContentAlignment" Value="Left"/&gt;
      &lt;Setter Property="VerticalContentAlignment" Value="Top"/&gt;
      &lt;Setter Property="VerticalScrollBarVisibility" Value="Visible"/&gt;
      &lt;Setter Property="Padding" Value="4"/&gt;
      &lt;Setter Property="BorderThickness" Value="1"/&gt;
      &lt;Setter Property="BorderBrush"&gt;
          &lt;Setter.Value&gt;
              &lt;LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"&gt;
                  &lt;GradientStop Color="#FFA3AEB9" Offset="0"/&gt;
                  &lt;GradientStop Color="#FF8399A9" Offset="0.375"/&gt;
                  &lt;GradientStop Color="#FF718597" Offset="0.375"/&gt;
                  &lt;GradientStop Color="#FF617584" Offset="1"/&gt;
              &lt;/LinearGradientBrush&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="ScrollViewer"&gt;
                  &lt;Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2"&gt;
                      &lt;Grid Background="{TemplateBinding Background}"&gt;
                          &lt;Grid.ColumnDefinitions&gt;
                              &lt;ColumnDefinition Width="*"/&gt;
                              &lt;ColumnDefinition Width="Auto"/&gt;
                          &lt;/Grid.ColumnDefinitions&gt;
                          &lt;Grid.RowDefinitions&gt;
                              &lt;RowDefinition Height="*"/&gt;
                              &lt;RowDefinition Height="Auto"/&gt;
                          &lt;/Grid.RowDefinitions&gt;
                          &lt;ScrollContentPresenter x:Name="ScrollContentPresenter" Cursor="{TemplateBinding Cursor}" ContentTemplate="{TemplateBinding ContentTemplate}" Margin="{TemplateBinding Padding}"/&gt;
                          &lt;Rectangle Grid.Column="1" Fill="#FFE9EEF4" Grid.Row="1"/&gt;
                          &lt;ScrollBar x:Name="VerticalScrollBar" Grid.Column="1" IsTabStop="False" Maximum="{TemplateBinding ScrollableHeight}" Margin="0,-1,-1,-1" Minimum="0" Orientation="Vertical" Grid.Row="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{TemplateBinding VerticalOffset}" ViewportSize="{TemplateBinding ViewportHeight}" Width="18"/&gt;
                          &lt;ScrollBar x:Name="HorizontalScrollBar" Grid.Column="0" Height="18" IsTabStop="False" Maximum="{TemplateBinding ScrollableWidth}" Margin="-1,0,-1,-1" Minimum="0" Orientation="Horizontal" Grid.Row="1" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{TemplateBinding HorizontalOffset}" ViewportSize="{TemplateBinding ViewportWidth}"/&gt;
                      &lt;/Grid&gt;
                  &lt;/Border&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>And my actual ListBox xaml is: </p>
  
  <pre><code>&lt;Grid x:Name="LayoutRoot" Background="Transparent" Height="250"&gt;
      &lt;ListBox x:Name="iListBox" DataContext="{Binding}" ItemsSource="{Binding Path=ListVM.MyCollection}" 
               BorderBrush="Transparent" Background="Transparent" 
               ItemContainerStyle="{StaticResource ListBoxItemStyle1}"&gt;
          &lt;ListBox.Template&gt;
              &lt;ControlTemplate TargetType="ItemsControl"&gt;
                  &lt;ScrollViewer Style="{StaticResource CustomScrollViewerStyle}"/&gt;
              &lt;/ControlTemplate&gt;
          &lt;/ListBox.Template&gt;
          &lt;ListBox.ItemTemplate &gt;
              &lt;DataTemplate &gt;
                  &lt;Grid Background="Transparent" Loaded="Grid_Loaded"&gt;
                      &lt;IReviewerList1:MyCollectionDataItem /&gt;
                  &lt;/Grid&gt; 
              &lt;/DataTemplate&gt;
          &lt;/ListBox.ItemTemplate&gt;
      &lt;/ListBox&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>Currently all I see is a scrollbar and no dataItems anymore. Was wondering what i was doing wrong? Any help would be great. </p>
  
  <p>Thanks </p>