I am working on a WPF main window and I am using a list box, and I want the list box to auto-scroll whenever new data is added. I used the ListBoxBehavior
class in the chosen answer for this question, and I added the following namespaces for the that class in my code:
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Windows;
using System.Windows.Controls;
using System.ComponentModel;
Also, in my XAML, I added the following:
<ListBox x:Name="IncomingData" FontSize="20" Grid.Column="1" Margin="10,10,10,0" Grid.Row="3" ItemsSource="{Binding SourceCollection}" lb:ListBoxBehavior.ScrollOnNewItem="true"/>
However, I am getting the following three errors in my XAML code regarding that line, and they are as following:
Error XDG0006 The namespace prefix "lb" is not defined
.Error XDG0008 ListBoxBehavior is not supported in a Windows Presentation Foundation (WPF) project
.Error XLS0415 The attachable property 'ScrollOnNewItem' was not found in type 'ListBoxBehavior'
.
I tried creating an object of a ListBox
type ListBox lb = new ListBox();
in the ListBoxBehavior
class, but that didn't change the situation. Also, ScrollOnNewItem
already exists in the class, so why is it not identifying it?
Is there a missing step that I should have done?
Any help is much appreciated!