c# - Center Grid according to Grid Cell in WPF -
i have grid in wpf application centered horizontally , vertically, no big deal. however, center entire grid according single grid cell instead of entire grid. possible? here small illustration of want achieve. want red cross center. first picture shows entire grid (the grid green square) being centered, second picture shows entire grid being centered according cell red cross. possible in xaml? didn't provide code on purpose because don't think that's necessary question, it's not have error or doesn't work, have no clue how achieve this.
there outer grid, inner grid , element should centered. outer , inner grid have equal row , column weights. layout adapts resize
<grid> <grid.rowdefinitions> <rowdefinition height="*"/> <rowdefinition height="2*"/> <rowdefinition height="*"/> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition width="*"/> <columndefinition width="*"/> <columndefinition width="*"/> <columndefinition width="*"/> </grid.columndefinitions> <grid grid.column="1" grid.columnspan="3" background="lightgray" grid.row="0" grid.rowspan="2"> <grid.columndefinitions> <columndefinition/> <columndefinition/> <columndefinition/> </grid.columndefinitions> <grid.rowdefinitions> <rowdefinition /> <rowdefinition /> <rowdefinition /> </grid.rowdefinitions> <border grid.row="0" grid.column="1" grid.columnspan="2" background="green"/> <border grid.row="1" grid.rowspan="2" grid.column="0" grid.columnspan="2" background="cyan"/> </grid> </grid>
Comments
Post a Comment