locked
Listview can't be scrolled after column changes width RRS feed

  • Question

  • I have a grid column and the only contents are a listview.   When first loaded, I can use the scroll wheel to scroll up and down the list.  That column can change size dynamically depending on the view of the app, however once the column width is resized using.

    this.WebColumnWidth.Width = new GridLength(4.5, GridUnitType.Star);

    The list can't be scrolled anymore using the scroll wheel.

    If I set the width to auto then I can't even scroll using the scroll bar.

    Is there a reason for this and is there a workaround?

    Thanks.

    Wednesday, August 8, 2012 10:54 PM

Answers

  • OK... the inability to scroll is by-design, although I think you won't like the design...  What happens is that the grid resizes which causes it to think that it can show all of the items in the list at the same time so it removes the ability to scroll.  The "workaround" is to explicitly set the width.  We had this same issue reported a while back.

    I don't quite understand the issue with the webview, other than "I can't set focus on it".  I'm not sure this is an issue, since the internal contents of a webview aren't directly addressable, so it's going to require the interaction of a user in any case.  Why do you need to do this?


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, August 14, 2012 2:43 PM
    Moderator

All replies

  • I tested this on RTM bits, it does not reproduce.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Friday, August 10, 2012 3:19 PM
    Moderator
  • I've written a sample program that shows the issues.  How can I get it to you?

    The first issue I mentioned only occurs when a webview is present and has navigated to either a uri or a string.  Then the listview must get focus again before it can be scrolled again.  Which is an issue because selecting an item in the listview navigates the webview which makes the listview unscrollable again.

    The auto width option is not dependent on anything at all.  If you have a columnwidth definition in XAML...

    <Grid.ColumnDefinitions>
            <ColumnDefinition x:Name="SampleColumnWidth" Width="300" />
    </Grid.ColumnDefinitions>

    And set it to auto in the code behind.

    this.SampleColumnWidth.Width = new GridLength(0, GridUnitType.Auto);

    Then it doesn't scroll at all.  Even with the scroll bar.  I think this issue might be because of the way I'm setting it to auto.  The grid width does change correctly, but I don't know if the code is right.

    I've got both examples and a third in my sample program.  The third example is a situation where a listview could either be text or a website and hides the webview.  Which adds another element to the scrolling issue.

    Thanks,
    Javier

    Saturday, August 11, 2012 3:48 AM
  • Okay, with issue one, I've got a workaround.  I'm able to set focus to the listview on pointerentered and pointermoved.  However, it has the adverse effect of disabling scrolling on the webview.  Which I would love to add back in the same fashion but I have 2 issues.

    1.  The webview doesn't have a .focus method.  Which I figured I could workaround by setting focus to it's container...which brings me to issue 2.

    2.  When a webview is placed inside of a container, neither the webview or the container's pointerentered event gets fired.  

    The third issue was also corrected by hiding the containing grid instead of hiding the webview itself.  However, it still suffers from the same side effects as with issue 1.

    Is there anyway to bring the focus back to the webview when on pointerentered that I'm missing?  Thanks!

    The autowidth issue still persists no matter what I do.  I believe this is a bug as I don't see any reason why the listview scrolling would break completely.


    Saturday, August 11, 2012 6:02 PM
  • What three issues are you referring to?  I only see one, the lack of listview to scroll after changing the width of the grid column.  That does not happen on RTM bits. 

    You can send a project to me MSMALL at Microsoft.


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, August 13, 2012 8:52 PM
    Moderator
  • I could see the confusion, this issue has evolved since the first post and my explanations became convoluted.

    At the beginning there were 2 issues with similar symptoms and triggers.

    1. When a column width is set to a pixel or star value, wheel scrolling breaks. After more testing I learned that this was due to a webview navigating to a site and removing focus from the listview.

    2. When a column width is set to "auto" all scrolling is completely broken. (this is the one I think is a bug)

    Then....issue 1. broke into two issues.

    1. A standard webview. Workaround...  Focus can be set to the listview using the pointer event.

    2. A webview who's visibility is set with binding.  The listview will never get focus.  Workaround... wrap the webview in a grid and bind the visibility of the grid.

    Which brings us to the fact that once I set the focus back to the listview in the code, there is no way I can set the focus to the webview on the pointer events as they don't fire.  Also, the webview has no focus() method.

    Please let me know if that cleared everything up.


    Monday, August 13, 2012 9:20 PM
  • OK... the inability to scroll is by-design, although I think you won't like the design...  What happens is that the grid resizes which causes it to think that it can show all of the items in the list at the same time so it removes the ability to scroll.  The "workaround" is to explicitly set the width.  We had this same issue reported a while back.

    I don't quite understand the issue with the webview, other than "I can't set focus on it".  I'm not sure this is an issue, since the internal contents of a webview aren't directly addressable, so it's going to require the interaction of a user in any case.  Why do you need to do this?


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, August 14, 2012 2:43 PM
    Moderator
  • As far as the auto size, I guess I can just wrap the entire contents in a grid and make it invisible.  If the grid column is already set to auto, hiding all the contents should in theory hide the column.  I'll have to test that theory out.

    As far as the webview, here is the issue in relation to the program I sent you.

    I click on a a listview item and it navigates the webview, I move the mouse to the webview, I can use the wheel to scroll.

    I move the mouse back to the listview, on the pointer entered event I give focus back to the list view, I can use the wheel to scroll.

    I move the mouse BACK to the webview, I can't use the wheel to scroll anymore.  Now I have to click the contents of the webview to be able to scroll again.  However, I actually have to click on an HTML element, not just anywhere on the page.  Then I can use the wheel to scroll again.  Until I move the mouse back over the listview.

    What I image would be the best user experience is to enable wheel scrolling on whatever element the mouse is currently over.  The user shouldn't have to click to browse the content.

    That's what I'm trying to achieve.

    Tuesday, August 14, 2012 2:51 PM
  • I'm not sure I agree with you - it doesn't fit with the rest of the way that Windows works. I have to interact with an element in order to control it. That said, the problem seems to be that WebView isn't a simple XAML control like other controls.  Check out this post:

    http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/7f1ac033-eaba-495a-92a5-699acaaa5484

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, August 14, 2012 3:55 PM
    Moderator
  • Fair enough.  Thanks for the help.
    Tuesday, August 14, 2012 4:45 PM