title: Wpf-how can I use a converter in order to display elements from a listbox while I am scrolling
body: <p>I have a big lists of objects which are binded to a ListBox. In that list box i am displaying the name of a file and a byte array of an image which is coming form WCF. I would display the files in the listbox depending on the scroll postion, so the file which are not visible from that scroll position to be set as Hidden.
  I found on the internet a way which might help me but i cannot see a way that this will work.
  I found convertors which should help me, and set up that class as a window resource. When I am opening the app all the items are converted to be visible.
  This is the class:</p>
  
  <pre><code>class NullVisibilityConverter : IValueConverter
  {
      public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
      {
          return value == null ? Visibility.Hidden : Visibility.Visible;
      }
  
      public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
      {
          return value == null ? Visibility.Visible : Visibility.Hidden;
      }
  }
  </code></pre>
  
  <p>In Xaml i setup this class as a window Resource and i binded the functionality to the image and name in the Listbox items</p>
  
  <pre><code>        &lt;Window.Resources&gt;
              &lt;view:NullVisibilityConverter x:Key="NullToVis"/&gt;
          &lt;/Window.Resources&gt;
      &lt;Image  Source="{Binding Path=Image}" Visibility="{Binding Path=Image, Converter={StaticResource NullToVis}}" Height="80" Width="80" Grid.Column="0"/&gt;
     &lt;StackPanel Grid.Column="1" Visibility="{Binding Path=Image, Converter={StaticResource NullToVis}}" Orientation="Vertical" Width="80" Height="30"&gt;
     &lt;TextBlock  Text="{Binding Path=Name}" Margin="5,1,0,1"/&gt;
      &lt;/StackPanel&gt;
  </code></pre>
  
  <p>Does anyone have any idea how this might work?</p>