none
ListView Bug? GridViewRowPresenter doesn't seem to resize properly

    Question

  • I noticed some strange behaviour when I tried to restyle a GridView ListView.
    It seems that the GridViewRowPresenter in the ControlTemplate doesn't resize correctly when resizing the columns in the ListView.

    Here are the steps to reproduce this:

    - Open a new WPF app and insert this XAML code in the main window:

             <ListView>
                <ListView.View>
                    <GridView>
                        <GridViewColumn Header="Col1"/>
                        <GridViewColumn Header="Col2"/>
                    </GridView>
                </ListView.View>
                <ListViewItem>Item</ListViewItem>
                <ListViewItem>Item</ListViewItem>
            </ListView>

    - Select a ListViewItem. Notice the round corners of the selection (see Screenhot)
    http://666kb.com/i/bd29txmntaqjx97on.png

    - Make one column larger
    - Make it smaller again
    http://666kb.com/i/bd29z9fv5nuw63t47.png

    - Make the window smaller, so that the width of the window is smaller than the previous (bigger) size of the column
    http://666kb.com/i/bd2a1t5xsh2fovndz.png

    - Notice that the selection is cut off on the right side:
    http://666kb.com/i/bd2a5k1jza8rpantz.png

    It seems that the GridViewRowPresenter is not able to reduce its width properly after a column was resized, therefore being bigger than the ListView.

    This is a problem for me as I am trying to restyle the ListViewItem to show a ToggleButton on the right side for pinning items, but when the user is resizing columns and/or the window, the ToggleButton might disappear. Im running .net 3.5 SP1 on Win7.

    Is this a known bug? Is there a quick work around?

    Thursday, October 08, 2009 3:12 PM

Answers

  • I'd say this is more like a poor feature. Don't expect this to change in the future and use Toolkit's DataGrid where this thing can easily be styled.


    Bigsby, Lisboa, Portugal
    O que for, quando for, é que será o que é...
    Wenn ist das Nunstruck git und Slotermeyer? Ja! ... Beiherhund das Oder die Flipperwaldt gersput!
    http://bigsby.eu
    • Proposed as answer by Kenneth Haugland Friday, October 09, 2009 7:33 AM
    • Marked as answer by Bruce.Zhou Thursday, October 15, 2009 1:33 PM
    Thursday, October 08, 2009 3:49 PM
  • I don't have a workaround but it does look like a bug. When you resize the window the list view's ItemsPresenter is resized correctly but the VirtualizingStackPanel within it seems to clamp at the maximum width of the columns regardless of the columns' current width. E.g. if you widen a column so that the total column width is 250 then shrink the column again the stack panel will still only resize down to 250.

    You should submit a bug on Connect but as Bigsby stated it might not get a high priority.
    • Proposed as answer by Kenneth Haugland Friday, October 09, 2009 7:33 AM
    • Marked as answer by Bruce.Zhou Thursday, October 15, 2009 1:33 PM
    Thursday, October 08, 2009 4:14 PM

All replies

  • I'd say this is more like a poor feature. Don't expect this to change in the future and use Toolkit's DataGrid where this thing can easily be styled.


    Bigsby, Lisboa, Portugal
    O que for, quando for, é que será o que é...
    Wenn ist das Nunstruck git und Slotermeyer? Ja! ... Beiherhund das Oder die Flipperwaldt gersput!
    http://bigsby.eu
    • Proposed as answer by Kenneth Haugland Friday, October 09, 2009 7:33 AM
    • Marked as answer by Bruce.Zhou Thursday, October 15, 2009 1:33 PM
    Thursday, October 08, 2009 3:49 PM
  • I don't have a workaround but it does look like a bug. When you resize the window the list view's ItemsPresenter is resized correctly but the VirtualizingStackPanel within it seems to clamp at the maximum width of the columns regardless of the columns' current width. E.g. if you widen a column so that the total column width is 250 then shrink the column again the stack panel will still only resize down to 250.

    You should submit a bug on Connect but as Bigsby stated it might not get a high priority.
    • Proposed as answer by Kenneth Haugland Friday, October 09, 2009 7:33 AM
    • Marked as answer by Bruce.Zhou Thursday, October 15, 2009 1:33 PM
    Thursday, October 08, 2009 4:14 PM
  • @Bigsby
    Thanks for the tip, I'll give the DataGrid a try.

    @dekurver
    Thanks for pointing me to Connect, I'll open up a bug report.
    Friday, October 09, 2009 6:21 AM
  • Hi,

    We see the same problem in our project too. We've built a control arround the ListView and we use it a lot in our project. We've not been able to solve this problem. If anyone knows a workaround, this would be greatly appreciated.

    Regards,
    Paul Sinnema.
    Diartis AG
    Take a look at my blog: http://paul.sinnema.ch
    Thursday, November 12, 2009 3:59 PM
  • Would writing our own view solve this problem?
    Take a look at my blog: http://paul.sinnema.ch
    Thursday, November 19, 2009 10:37 AM