xaml - WPF Custom Buttons below ListBox Items -
wpf experts -
i trying add buttons below custom listbox , have scroll bar go bottom of control. items should move , not buttons. hoping guidance on best way achieve this. thinking itemspaneltemplate needed modified not certain.
thanks
alt text http://i41.tinypic.com/15p4c35.jpg
my code below
<!-- list item selected --> <lineargradientbrush x:key="gotfocusstyle" endpoint="0.5,1" startpoint="0.5,0"> <lineargradientbrush.gradientstops> <gradientstop color="black" offset="0.501"/> <gradientstop color="#ff091f34"/> <gradientstop color="#ff002f5c" offset="0.5"/> </lineargradientbrush.gradientstops> </lineargradientbrush> <!-- list item hover --> <lineargradientbrush x:key="mouseoverfocusstyle" startpoint="0,0" endpoint="0,1"> <lineargradientbrush.gradientstops> <gradientstop color="#ff013b73" offset="0.501"/> <gradientstop color="#ff091f34"/> <gradientstop color="#ff014a8f" offset="0.5"/> <gradientstop color="#ff003363" offset="1"/> </lineargradientbrush.gradientstops> </lineargradientbrush> <!-- list item selected --> <lineargradientbrush x:key="lostfocusstyle" endpoint="0.5,1" startpoint="0.5,0"> <lineargradientbrush.relativetransform> <transformgroup> <scaletransform centerx="0.5" centery="0.5"/> <skewtransform centerx="0.5" centery="0.5"/> <rotatetransform centerx="0.5" centery="0.5"/> <translatetransform/> </transformgroup> </lineargradientbrush.relativetransform> <gradientstop color="#ff091f34" offset="1"/> <gradientstop color="#ff002f5c" offset="0.4"/> </lineargradientbrush> <!-- list item highlight --> <solidcolorbrush x:key="listitemhighlight" color="#ffe38e27" /> <!-- list item unhighlight --> <solidcolorbrush x:key="listitemunhighlight" color="#ff6fb8fd" /> <style targettype="listboxitem"> <eventsetter event="gotfocus" handler="listitem_gotfocus"></eventsetter> <eventsetter event="lostfocus" handler="listitem_lostfocus"></eventsetter> </style> <datatemplate x:key="customlistdata" datatype="{x:type listboxitem}"> <border borderbrush="black" borderthickness="1" margin="-2,0,0,-1"> <grid> <grid.columndefinitions> <columndefinition width="{binding relativesource={relativesource findancestor, ancestortype={x:type listboxitem}}, path=actualwidth}" /> </grid.columndefinitions> <label verticalcontentalignment="center" borderthickness="0" borderbrush="transparent" foreground="{staticresource listitemunhighlight}" fontsize="24" tag="{binding .}" grid.column="0" minheight="55" cursor="hand" fontfamily="arial" focusvisualstyle="{x:null}" keyboardnavigation.tabnavigation="none" background="{staticresource lostfocusstyle}" mousemove="listitem_mouseover" > <label.contextmenu> <contextmenu name="editmenu"> <menuitem header="edit"/> </contextmenu> </label.contextmenu> <textblock text="{binding .}" margin="15,0,40,0" textwrapping="wrap"></textblock> </label> <image tag="{binding .}" source="{binding}" margin="260,0,0,0" grid.column="1" stretch="none" width="16" height="22" horizontalalignment="center" verticalalignment="center" /> </grid> </border> </datatemplate> </window.resources> <window.datacontext> <objectdataprovider objecttype="{x:type local:imageloader}" methodname="loadimages" /> </window.datacontext> <listbox itemssource="{binding}" width="320" background="#ff021422" borderbrush="#ff1c4b79" > <listbox.resources> <solidcolorbrush x:key="{x:static systemcolors.highlightbrushkey}">transparent</solidcolorbrush> <style targettype="{x:type listbox}"> <setter property="scrollviewer.horizontalscrollbarvisibility" value="disabled" /> <setter property="itemtemplate" value="{staticresource customlistdata }" /> </style> </listbox.resources> </listbox>
why don't place 2 controls (the list , buttons panel) stackpanel?
<stackpanel horizontalalignment="left" margin="0,0,0,0" width="240"> <listbox height="320"/> <button content="buttons go here"/> </stackpanel>
you won't listbox's scrollbar go bottom of screen, fix putting in scrollbar control.
editing templates might yield want may run point items @ bottom of list hidden button panel. overcome increasing bottom padding of last item in list or similar margin/padding hack.
however, don't think sizing scrollbar bottom best idea in terms of common sense in user interfaces scrollbars should conventionally placed on side of scrollable.
Comments
Post a Comment