The last line WPF listbox horizontal scrollbar last screen of the display incomplete

Original: WPF the ListBox horizontal scroll bar in the last line of the last screen display incomplete

Problem: WPF listbox horizontal scrollbar last screen display incomplete last line of
code is as follows:


   
   
  1. <ListBox
  2.       Width= "200"
  3.       Height= "200"
  4.       FontSize= "18"
  5.      >
  6.       <ListBoxItem>item1 </ListBoxItem>
  7.       <ListBoxItem>item2 </ListBoxItem>
  8.       <!-----item3,4...13------->
  9.       <ListBoxItem>item14 </ListBoxItem>
  10.       <ListBoxItem>item15================= </ListBoxItem>
  11.       <ListBoxItem>item16 </ListBoxItem>
  12.       <!-----item17,18...21------->
  13.       <ListBoxItem>item22 </ListBoxItem>
  14.   </ListBox>

Phenomenon: listbox items in an amount sufficient to display the vertical scroll bar,
the first item the last screen (upper item15 ===) is too long that the horizontal scroll bar display listbox.
Solution:
In the listbox by adding the following:
ScrollViewer.CanContentScroll = "False"
or another horizontal scroll bar is always displayed
ScrollViewer.HorizontalScrollBarVisibility = "Visible"

Analysis:
Default ScrollViewer.CanContentScroll = "True", click on the listbox vertical scroll bar to scroll down when a height of each item of rolling,
at this time, when the last screen, since the horizontal scroll bar appears, blocking the last row.
ScrollViewer.CanContentScroll = "False" when a continuous scroll down, ListBox can scroll to the bottom. The above problem does not exist.

The
ScrollViewer.HorizontalScrollBarVisibility = "Visible", because it has been shown that there is no problem to occupy listbox height.

Reproduced in: https: //my.oschina.net/xhan/blog/24443

Guess you like

Origin www.cnblogs.com/lonelyxmas/p/12387741.html