WPF ListView Always show complete items -


i've got app multiple listview controls there's requirement item's in listview must visible. there should never partial listviewitem's showing in list. if user releases scrollviewer @ position ends showing partial item, list should "snap" , correct complete items displayed.

has done before? think i'm going need overload listview and/or scrollviewer this. i'm looking suggestions on how approach this. thanks.

here 1 of lists:

<ctrls:snaplist x:name="part_productlist"                                              scrollviewer.cancontentscroll="false"                                               scrollviewer.verticalscrollbarvisibility="auto"                                              scrollviewer.horizontalscrollbarvisibility="hidden"                                             itemcontainerstyle="{staticresource productfinderitem}"                                              canvas.top="373" canvas.left="75"                                             height="910" width="900" >                              <ctrls:snaplist.itemspanel>                                     <itemspaneltemplate>                                         <virtualizingstackpanel virtualizingstackpanel.isvirtualizing="true" virtualizingstackpanel.virtualizationmode="standard" />                                 </itemspaneltemplate>                             </ctrls:snaplist.itemspanel>                              <ctrls:snaplist.template>                                     <controltemplate>                                     <scrollviewer  x:name="scroller" verticalalignment="top"  cancontentscroll="true" style="{staticresource vertscrollviewer}" focusable="false" >                                                 <itemspresenter   />                                             </scrollviewer>                                     </controltemplate>                             </ctrls:snaplist.template>                         </ctrls:snaplist> 

i believe you're looking scrollviewer.cancontentscroll property

if know maximum size of item in listview, make sure listview's height same size, or multiple of item height.

working example:

<listview scrollviewer.cancontentscroll="true"             height="200">      <listboxitem height="50"                     content="test1" />     <listboxitem height="50"                     content="test2" />     <listboxitem height="50"                     content="test3" />     <listboxitem height="50"                     content="test4" />     <listboxitem height="50"                     content="test5" />     <listboxitem height="50"                     content="test6" />     <listboxitem height="50"                     content="test7" />     <listboxitem height="50"                     content="test8" />     <listboxitem height="50"                     content="test9" />     <listboxitem height="50"                     content="test10" />  </listview> 

content in scrollviewer can scrolled in terms of physical units or logical units. physical units device independent pixels. logical units used scrolling items within itemscontrol. default behavior of scrollviewer use physical units scroll content. however, in cases cancontentscroll set true, content use logical units scroll. example, listbox, listview, , other controls inherit itemscontrol use logical units scroll. if cancontentscroll true, values of extentheight, scrollableheight, viewportheight, , verticaloffset properties number of items, instead of physical units.

if require physical scrolling instead of logical scrolling, wrap host panel element in scrollviewer , set cancontentscroll property false. physical scrolling default scroll behavior panel elements.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -