This is a mirror of official site: http://jasper-net.blogspot.com/

Changing the viewport of a listbox in WPF

| Thursday, November 18, 2010
One of the nice thing about the WPF controls is the ability for them to mimic almost anything….In my case I wanted to recreate an old Winform sample of a NASDAQ sales status board…Which required a grid to draw different colors, show new items being added – but do it with out scrollbars…Turns out the WPF Listbox does all this with no or very little code at all – in most cases just a little mark up.

So how did I do this:

1. Eliminate the Scrollbars:

ScrollViewer.HorizontalScrollBarVisibility="Hidden"

2. Have the listbox show the last item (to simulate scrolling updates) is one line of code you add after you have added an item:

ListBox1.ScrollIntoView(ListBox1.Items(ListBox1.Items.Count - 1))

3. To change the colors on a item by item basis is also one line of code i.e.

listitem = New ListBoxItem

listitem.Foreground = New SolidColorBrush(Colors.Sienna)

ListBox1.Items.Add(listitem)

So with the use of MSMQ I was able to write an order simulator pretty quickly!

(The colors are the priority of the message that was sent)

Read more: Ozzie Rules Blogging

Posted via email from .NET Info

0 comments: