WPF Bug List (13)--ListView horizontal scroll bar that should appear but not appear

Source: Internet
Author: User

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 ... )

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.