title: WPF Marquee Text Animation in ListView
body: <p>I'm trying to add marquee text animation in my code. I found working code in
  <a href="https://stackoverflow.com/questions/15323163/wpf-marquee-text-animation">WPF Marquee Text Animation</a>
  But when i trying to add it to my ItemContainerStyle i got error: The namespace prefix &quot;Local&quot; is not defined. Maybe someone can help me.
  i'm not sure how to define <strong>NegatingConverter</strong> in my Item Container Style. Thx.</p>
  <p>Error code line:</p>
  <pre><code> &lt;local:NegatingConverter x:Key=&quot;NegatingConverter&quot; /&gt;
  </code></pre>
  <p>Code:</p>
  <pre><code>namespace Line1_9_WPF
  {
      public class NegatingConverter : IValueConverter
      {
  
          public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
          {
              if (value is double)
              {
                  return -((double)value);
              }
              return value;
          }
  
          public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
          {
              if (value is double)
              {
                  return +(double)value;
              }
              return value;
          }
      }
  }
  </code></pre>
  <p>Xaml:</p>
  <pre><code>             &lt;ListView ItemsSource=&quot;{Binding Messages}&quot;
                                Background=&quot;Transparent&quot;
                        
                                BorderBrush=&quot;Transparent&quot;
                                ItemContainerStyle=&quot;{StaticResource ChatItem}&quot;
                                Margin=&quot;8,0,0,0&quot;
                      Grid.Row=&quot;1&quot;
                  &gt;
                  &lt;/ListView&gt;
  </code></pre>
  <p>ItemContainerStyle:</p>
  <pre><code>&lt;ResourceDictionary xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
                      xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;&gt;
      &lt;Style TargetType=&quot;ListViewItem&quot; x:Key=&quot;ChatItem&quot;&gt;
          &lt;Setter Property=&quot;Background&quot;  Value=&quot;#393B40&quot;/&gt;
          &lt;Setter Property=&quot;Template&quot;&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate&gt;
  
                          &lt;StackPanel Orientation=&quot;Vertical&quot;&gt;
                              &lt;Label Content=&quot;{Binding Line}&quot;
                                 Foreground=&quot;White&quot;
                                /&gt;
                          &lt;Label Content=&quot;{Binding MessageF1}&quot;
                                 Foreground=&quot;Gray&quot;
                                /&gt;
                          &lt;Label Content=&quot;{Binding MessageF2}&quot;
                                 Foreground=&quot;Gray&quot;
                                /&gt;
  
                          &lt;Label Content=&quot;{Binding Time}&quot;
                                 Foreground=&quot;Gray&quot;
                                /&gt;
                          &lt;StackPanel Orientation=&quot;Horizontal&quot; x:Name=&quot;stack&quot;&gt;
                              &lt;StackPanel.Resources&gt;
                                  &lt;local:NegatingConverter x:Key=&quot;NegatingConverter&quot; /&gt;
                                  &lt;Storyboard x:Key=&quot;slide&quot;&gt;
                                      &lt;DoubleAnimation From=&quot;0&quot; To=&quot;{Binding Width, ElementName=canvas, Converter={StaticResource NegatingConverter}}&quot; Duration=&quot;00:00:03&quot;
                        Storyboard.TargetProperty=&quot;X&quot;
                        Storyboard.TargetName=&quot;transferCurreny&quot;
                        RepeatBehavior=&quot;Forever&quot;/&gt;
                                  &lt;/Storyboard&gt;
                              &lt;/StackPanel.Resources&gt;
                              &lt;StackPanel.RenderTransform&gt;
                                  &lt;TranslateTransform x:Name=&quot;transferCurreny&quot; X=&quot;0&quot;/&gt;
                              &lt;/StackPanel.RenderTransform&gt;
                              &lt;StackPanel.Triggers&gt;
                                  &lt;EventTrigger RoutedEvent=&quot;StackPanel.Loaded&quot;&gt;
                                      &lt;BeginStoryboard Storyboard=&quot;{StaticResource slide}&quot; /&gt;
                                  &lt;/EventTrigger&gt;
                                  &lt;EventTrigger RoutedEvent=&quot;StackPanel.SizeChanged&quot;&gt;
                                      &lt;BeginStoryboard Storyboard=&quot;{StaticResource slide}&quot; /&gt;
                                  &lt;/EventTrigger&gt;
                              &lt;/StackPanel.Triggers&gt;
                              &lt;Canvas x:Name=&quot;canvas&quot; Width=&quot;{Binding ActualWidth, ElementName=stack}&quot;&gt;
                                  &lt;TextBlock Text=&quot;StackOverflow&quot; FontSize=&quot;25&quot;  x:Name=&quot;txtKron&quot; Canvas.Left=&quot;0&quot;/&gt;
                                  &lt;TextBlock Text=&quot;{Binding Text, ElementName=txtKron}&quot; FontSize=&quot;25&quot; Canvas.Left=&quot;{Binding Width, ElementName=canvas}&quot;/&gt;
                              &lt;/Canvas&gt;
                          &lt;/StackPanel&gt;
                      &lt;/StackPanel&gt;
  
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
      
  &lt;/ResourceDictionary&gt;
  </code></pre>