i've got grid 3 columns: first has width set "*", have been led believe make fill remaining space left other columns. second has width of 8, , third's width set "auto" size changes depending on contents.
in 2nd column have gridsplitter, when dragged can change width of both first , third columns. works fine, issue have grid in third column that, when toggled, have visibility set collapsed. when collapsed, need first column fill of remaining space. tried many ways:
- set
horizontalalignmenton first columnstretch - bound
grid.rowspanof first column visibility of third one, when when hidden rowspan change 3 and, since width using "*", should theoretically use of available space in 3 columns.
the weird thing that, if not resize columns using gridsplitter, first column fill remaining space properly. yet after resizing, first column not budge. it's if, when dragging gridsplitter resize columns, wpf change width of both columns become absolute instead of star , auto values, making not fill space after resize.
xaml code (condensed) requested:
<grid grid.row="1"> <grid.columndefinitions> <columndefinition width="*"/> <columndefinition width="auto"/> <columndefinition width="auto"/> </grid.columndefinitions> <grid x:name="assetlistviewgrid" grid.column="0" grid.rowspan="{binding visibility, elementname=assetviewmetadatasplitter, converter={staticresource splittervisibilitytorowspanconverter}}" margin="0 4 0 4"> <!-- irrelevant code --> </grid> <gridsplitter x:name="assetviewmetadatasplitter" grid.column="1" opacity="0.8" horizontalalignment="center" width="6" margin="3 5 1 5" tooltip="grab resize" visibility="{binding ischecked, elementname=gridheadervisibilitytogglebutton, converter={staticresource visconverter}}"/> <grid x:name="metadatagrid" margin="4 2 4 2" grid.column="2" datacontext="{binding metadataviewmodel}" visibility="{binding ischecked, elementname=gridheadervisibilitytogglebutton, converter={staticresource visconverter}}"> <!-- irrelevant code --> </grid>
i ran well. in app seemed gridsplitter in fact changing width values absolute instead of * also, i'm guessing behavior.
i ended using code-behind solve it. first, name column 1:
<columndefinition width="*" x:name="column1"/> then, add event handler when metadatagrid visibility changes, & call code reset column1 * width fill rest:
column1.width = new gridlength(1, gridunittype.star); you might try doing in xaml style triggers reset column1 width * based on metadatagrid's visibility state. case more complex custom sizes & varied conditions & expanders, used code-behind, i'm not sure if xaml triggers work or not . helps though.
Comments
Post a Comment