We know that the ListView will display the scroll bar by default when the content is outside the control's scope. This content, obviously, should include head and items two parts. Regardless of which part is exceeded, you should display the horizontal scroll bar.
The ListView bug is that the horizontal scroll bar does not appear when there is no item in the ListView and the total length of the Headr exceeds the ListView itself.
This bug is a good replay. The code is as follows:
<grid x:name= "LayoutRoot" >
<listview width= ">
<ListView.View> <GridView>"
<gridviewcolumn
header= "Name"/>
<gridviewcolumn
header= "Value"/> <gridviewcolumn header=
"Length"/ >
<gridviewcolumn
header= "Format"/>
<gridviewcolumn header= "Error
Information"/ >
</GridView>
</ListView.View>
</ListView>
</Grid>
The effect is as shown in the following illustration:
This may be the simplest problem I've ever discovered, but it's a complicated bug.
Where is the problem? Carefully analyze the XAML Structure of ListView, as shown in the following figure:
In ListView's template, we saw no headerpresenter in ScrollViewer, but only itemspresenter. So where is Headerpresenter? There is nothing wrong, just in the ScrollViewer. As shown in the following figure.
The problem is here, the headerpresenter in the template of ScrollViewer is not part of the content that needs to be scroll. So when the header goes out of range, the ScrollViewer scrollbar doesn't appear. Why does Microsoft want to put Headerpresenter in ScrollViewer's template?
Think about scrolling the vertical scroll bar, is not only items scrolling? And the header is always on top? If you use the header as the content, the header will also scroll along with the items. This is a bug that does not appear larger than the super long header horizontal scroll bar. So under the constraints of WPF's existing control Sets, this is the only way.
However, the horizontal scroll bar does not appear when there are no items, and remains a bug. The solution to this bug is quite complex and requires selective scrolling functionality (provided by the WPF Toolkit). The solution is explained next time. If I can make it through the time I can accept ... )