I have a ListView
with custom-made cells (items).
This ListView
represents a conversation between two persons exchanging messages with my application. Each time a message is added, the conversation auto-scrolls to the last item.
I am facing a few "strange" issues :
When a user writes a rather long message (say, 10 lines), it can then take up almost the whole screen (meaning the space allocated to the ListView
) which is normal of course but then the scrolling is somewhat broken.
First, when the list auto-scrolls to this message, a big white space appears below the item all the way down to the bottom of my ListView
. See picture :
And when messages are very short (single line) :
Second, and in all cases, the scroll speed is way to fast. A single mous-wheel "stroke" (the feeling in your finger as you scroll) will move the scroll bar too fast : up to 4 small messages are scrolled ! That's too much !
So question is : how to control the scroll speed ? How to slow it down ? Why is there this big white space ? Thanks for the help !
[UPDATE 1]
Requested by @CurtisHx my ListView XAML
is as follow :
I hope it helps understanding my issue!
One way to be to set
ScrollViewer.CanContentScroll="False"
on theListView
. https://social.msdn.microsoft.com/Forums/vstudio/en-US/47bd6a75-7791-4c0f-93ae-931e9a6540e7/smooth-scrolling-on-listbox?forum=wpfYou will loose virtualization on the
ListView
, so keep the number of elements in theListView
to something reasonable. That should fix the fast scroll speed.Text Alignment
The text is being aligned correctly. Currently, the parent container limits the width of the
TextBlocks
.TextBlocks
will fill all of the horizontal space it can before wrapping the text. So for long messages, theTextBlock
will expand horizontally until it hits the limits of the parent container.In order to get the staggered text, the width of the message needs to be less than width of the
ListView
. If you widen the window, you'll see the text become staggered. Below is a snippit of code, pointing out theTextBlock
that needs to be width limited.