Saturday 15 September 2012

wpf controls - WPF - Stackpanel won't wrap -



wpf controls - WPF - Stackpanel won't wrap -

i have stackpanel dynamically add together 50x50 rectangles to. want display 6 in per line , automatically add together line approaches threshold per. (i.e. 12 rectangles == 2 lines.) can't seem wrap though. here's xaml code (i've cutting off stuff in other rows suspect not relevant):

<grid> <grid.columndefinitions> <columndefinition width="60"/> <columndefinition width="140"/> <columndefinition width="2*"/> <columndefinition width="auto"/> </grid.columndefinitions> <grid.rowdefinitions> <rowdefinition height="80"/> <rowdefinition height="80"/> <rowdefinition height="230"/> <rowdefinition height="auto"/> </grid.rowdefinitions> <textblock fontweight="bold" fontsize="14" grid.columnspan="3">swatch thumbnails</textblock> <stackpanel x:name="sp_thumbnails" width="300" grid.row="0" grid.columnspan="3" orientation="horizontal" margin="0,15,0,0"> </stackpanel> <stackpanel grid.row="1" grid.columnspan="3" orientation="horizontal" margin="0,0,0,10"> <textblock height="50" width="50" margin="0,0,4,0" > <textblock.background> <solidcolorbrush color="{dynamicresource {x:static systemcolors.activecaptioncolorkey}}"/> </textblock.background></textblock> <textblock height="50" width="50" margin="0,0,4,0" > <textblock.background> <solidcolorbrush color="{dynamicresource {x:static systemcolors.activecaptioncolorkey}}"/> </textblock.background></textblock> <textblock height="50" width="50" margin="0,0,4,0" > <textblock.background> <solidcolorbrush color="{dynamicresource {x:static systemcolors.activecaptioncolorkey}}"/> </textblock.background></textblock> <textblock height="50" width="50" margin="0,0,4,0" > <textblock.background> <solidcolorbrush color="{dynamicresource {x:static systemcolors.activecaptioncolorkey}}"/> </textblock.background></textblock> <textblock height="50" width="50" margin="0,0,4,0" > <textblock.background> <solidcolorbrush color="{dynamicresource {x:static systemcolors.activecaptioncolorkey}}"/> </textblock.background></textblock> <textblock height="50" width="50" margin="0,0,4,0" > <textblock.background> <solidcolorbrush color="{dynamicresource {x:static systemcolors.activecaptioncolorkey}}"/> </textblock.background></textblock> </stackpanel>

use uniformgrid , set columns property 6:

<uniformgrid columns="6"> ... </uniformgrid>

wpf wpf-controls

No comments:

Post a Comment