c# - How to make a certain section scrollable -
i have got following xaml:
<stackpanel horizontalalignment="center"> <image name="logo" source="logo.png" margin="0,0,0,50"/> <scrollviewer> <dashboard_control:alignablewrappanel x:name="wrappanel"/> </scrollviewer> <textblock fontweight="bold" horizontalalignment="center" x:name="txtbottomtext"></textblock> </stackpanel>
i wrappanel
scrollable only, txtbottomtext
control @ bottom scroll, , logo
image control @ top - allowing wrappanel
scrollable.
i have tried adding scrollviewer shown above, never shows. tried adding property have vertical scrollbar, appears without letting me scroll (the scrollbar disabled).
i suspect because wrappanel's content dynamically generated @ run-time so:
wrappanel.children.add(content);
any ideas can fix this?
it's not because of wrappanel's content. because you're using stackpanel contain everything.
stackpanels grow indefinitely in direction determined orientation
property. default, that's vertically.
in case, makes scrollviewer "think" has enough available space stretch accomodate content, instead of activating scroll bars. gets bigger wrappanel inside gets bigger, pushing textblock down.
to avoid this, need use different panel able assign available space each control. grid.
<grid horizontalalignment="center"> <grid.rowdefinitions> <rowdefinition height="auto" /> <rowdefinition height="*" /> <rowdefinition height="auto" /> </grid.rowdefinitions> <image name="logo" source="logo.png" margin="0,0,0,50"/> <scrollviewer grid.row="1"> <dashboard_control:alignablewrappanel x:name="wrappanel"/> </scrollviewer> <textblock grid.row="2" fontweight="bold" horizontalalignment="center" x:name="txtbottomtext"></textblock> </grid>
i stackpanels tend overused :p they're practical , easy use, have bunch of quirks , limitations make them not suitable many situations, one.
edit: make sure, also, grid not contained inside vertical stackpanel, grid row height set auto
, or that.
Comments
Post a Comment