c# - VirtualizingStackPanel and HierarchicalDataTemplate -


i want use virtualizingstackpanel in treeview. when set virtualizingstackpanel.isvirtualizing true, scrolling not working properly. setting virtualizingpanel.scrollunit="pixel" doesn't work me. can smooth scrolling in virtualization mode?

<treeview name="treeview"            virtualizingstackpanel.isvirtualizing="true"            virtualizingstackpanel.virtualizationmode="recycling"            allowdrop="true"            virtualizingpanel.scrollunit="pixel">     <treeview.itemcontainerstyle>         <style targettype="{x:type treeviewitem}">             <style.triggers>                 <trigger property="isselected" value="true">                     <setter property="local:treeviewitembehavior.bringintoviewwhenselected" value="true" />                 </trigger>             </style.triggers>         </style>     </treeview.itemcontainerstyle>     <treeview.resources>             <datatemplate datatype="{x:type local:foldertreeviewdirectoryitem}" x:key="normalfoldertemplate" >             <virtualizingstackpanel orientation="horizontal" local:pixelbasedscrollingbehavior.isenabled="true" isitemshost="false">                     <image width="16" height="16" margin="4,0,0,2" snapstodevicepixels="true"  renderoptions.bitmapscalingmode="nearestneighbor" style="{staticresource foldertreeviewfolderimage}"></image>                 <textblock text="{binding path=name,mode=twoway}" tooltip="{binding path=path}" height="20" padding="4,2,4,0" style="{staticresource foldertreeviewtextstyle}"/>                 </virtualizingstackpanel>              </datatemplate>         <datatemplate datatype="{x:type local:foldertreeviewdirectoryitem}" x:key="editfoldertemplate">             <virtualizingstackpanel orientation="horizontal" local:pixelbasedscrollingbehavior.isenabled="true" isitemshost="false">                     <image width="16" height="16" margin="4,0,0,2" snapstodevicepixels="true"  renderoptions.bitmapscalingmode="nearestneighbor" style="{staticresource foldertreeviewfolderimage}"></image>                 <textbox text="{binding path=name}" lostfocus="folderrenametextbox_onlostfocus" initialized="frameworkelement_oninitialized" keydown="folderrenametextbox_keydown"  padding="4,2,4,0" style="{dynamicresource {x:static themes:sharedresourcekeys.textboxbasestylekey}}"></textbox>                 </virtualizingstackpanel>             </datatemplate>         <hierarchicaldatatemplate datatype="{x:type local:foldertreeviewdirectoryitem}"           itemssource="{binding items}">                 <contentcontrol content="{binding }">                     <contentcontrol.style>                         <style targettype="{x:type contentcontrol}">      <setter property="contenttemplate" value="{staticresource normalfoldertemplate}" />                             <style.triggers>                                 <datatrigger binding="{binding folderrename}" value="true">                                     <setter property="contenttemplate" value="{staticresource editfoldertemplate}" />                                 </datatrigger>                             </style.triggers>                         </style>                     </contentcontrol.style>                 </contentcontrol>             </hierarchicaldatatemplate>          <datatemplate datatype="{x:type local:foldertreeviewfileitem}" x:key="normalfiletemplate" >             <virtualizingstackpanel orientation="horizontal" local:pixelbasedscrollingbehavior.isenabled="true" isitemshost="false">                     <image width="16" height="16" margin="4,0,0,2" snapstodevicepixels="true"  renderoptions.bitmapscalingmode="nearestneighbor" style="{staticresource foldertreeviewfileimage}"></image>                     <textblock text="{binding path=name,mode=twoway}" tooltip="{binding path=path}" height="20" padding="4,2,4,0" style="{staticresource foldertreeviewtextstyle}"/>                 </virtualizingstackpanel>             </datatemplate>         <datatemplate datatype="{x:type local:foldertreeviewfileitem}" x:key="editfiletemplate">             <virtualizingstackpanel orientation="horizontal" local:pixelbasedscrollingbehavior.isenabled="true" isitemshost="false">                     <image width="16" height="16" margin="4,0,0,2" snapstodevicepixels="true"  renderoptions.bitmapscalingmode="nearestneighbor" style="{staticresource foldertreeviewfileimage}"></image>                 <textbox text="{binding path=name}"  padding="4,2,4,0" style="{dynamicresource {x:static themes:sharedresourcekeys.textboxbasestylekey}}"></textbox>                 </virtualizingstackpanel>             </datatemplate>         <datatemplate datatype="{x:type local:foldertreeviewfileitem}">             <contentcontrol content="{binding}">                 <contentcontrol.style>                     <style targettype="{x:type contentcontrol}">                         <!-- default template -->     <setter property="contenttemplate" value="{staticresource normalfiletemplate}" />     <style.triggers>                             <datatrigger binding="{binding filerename}" value="true">                                 <setter property="contenttemplate" value="{staticresource editfiletemplate}" />                             </datatrigger>                         </style.triggers>                     </style>                 </contentcontrol.style>             </contentcontrol>         </datatemplate>     </treeview.resources> </treeview> 

up http://i.stack.imgur.com/liosc.png down http://i.stack.imgur.com/f6nfa.png