xaml - Ignore horizontal mouse scrolling with nested ScrollViewer -


i have scrollviewer around grid vertically scroll it's content.

<scrollviewer>     <grid background="{themeresource applicationpagebackgroundthemebrush}">     ...     </grid> </scrollviewer> 

inside of grid have scrollviewer horizontal content.

<grid>     <scrollviewer name="scrollviewer" verticalscrollmode="disabled" verticalscrollbarvisibility="disabled" horizontalscrollmode="disabled" horizontalscrollbarvisibility="hidden">     ...     </scrollviewer>     <button name="buttonright" horizontalalignment="right" verticalalignment="stretch" tapped="buttonright_tapped" />     <button name="buttonleft" horizontalalignment="left" verticalalignment="stretch" tapped="buttonleft_tapped" /> <grid> 

the horizontalscrollmode disabled , horizontalscrollbarvisibility hidden because mouse input, want scroll content left/right buttons. horizontalscrollmode disabled prevent horizontal scrolling when mouse inside scrollviewer.

private void buttonright_tapped(object sender, tappedroutedeventargs e) {       scrollviewer.changeview(scrollviewer.horizontaloffset + scrollviewer.actualwidth, 0, 1); } 

with configuration can scroll page vertically when mouse inside horizontal scrollviewer. here image give idea: enter image description here

the problem touch. how can still scroll horizontally when user using touch device? when enable horizontalscrollmode touch works desired, mouse scrolls horizontally try prevent.

is there way ignore horizontal scrolling nested scrollviewers?

i found pretty simple solution solve problem.

i've added pointerentered nested horizontal scrollviewer

<scrollviewer name="scrollviewer" pointerentered="scrollviewerimages_pointerentered" verticalscrollmode="disabled" verticalscrollbarvisibility="disabled" horizontalscrollmode="disabled" horizontalscrollbarvisibility="hidden"> ... </scrollviewer> 

and enabled horizontalscrollmode when pointerdevicetype touch.

private void scrollviewerimages_pointerentered(object sender, pointerroutedeventargs e) {     if (e.pointer.pointerdevicetype == pointerdevicetype.touch)         scrollviewerimages.horizontalscrollmode = scrollmode.enabled;     else         scrollviewerimages.horizontalscrollmode = scrollmode.disabled; } 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -