grid - wpf gridlines - changing style -
is there way change style of gridlines in wpf grid? need divide grid 4 cells. used rowdefinitions , columndefinitions. need user distinguish cell which, that's why need change color of gridlines.
it depends on going for. in wpf, there different ways anything. here couple of easier ones.
the easiest way set showgridlines="true":
<grid horizontalalignment="stretch" verticalalignment="stretch" margin="5" showgridlines="true"> <grid.columndefinitions> <columndefinition width="*" /> <columndefinition width="*" /> </grid.columndefinitions> <grid.rowdefinitions> <rowdefinition height="*" /> <rowdefinition height="*" /> </grid.rowdefinitions> <textblock grid.column="0" grid.row="0" text="(0,0)" /> <textblock grid.column="1" grid.row="0" text="(1,0)" /> <textblock grid.column="0" grid.row="1" text="(0,1)" /> <textblock grid.column="1" grid.row="1" text="(1,0)" /> </grid>
that gives grid like:
you can use rectangle in each cell of grid different effects. here, fill transparent , stroke blue:
<grid horizontalalignment="stretch" verticalalignment="stretch" margin="5"> <grid.columndefinitions> <columndefinition width="*" /> <columndefinition width="*" /> </grid.columndefinitions> <grid.rowdefinitions> <rowdefinition height="*" /> <rowdefinition height="*" /> </grid.rowdefinitions> <rectangle grid.column="0" grid.row="0" stroke="blue" fill="transparent" /> <textblock grid.column="0" grid.row="0" text="(0,0)" /> <rectangle grid.column="1" grid.row="0" stroke="blue" fill="transparent" /> <textblock grid.column="1" grid.row="0" text="(1,0)" /> <rectangle grid.column="0" grid.row="1" stroke="blue" fill="transparent" /> <textblock grid.column="0" grid.row="1" text="(0,1)" /> <rectangle grid.column="1" grid.row="1" stroke="blue" fill="transparent" /> <textblock grid.column="1" grid.row="1" text="(1,0)" /> </grid>
that produces this:
alternatively, can fill rectangles , not give them stroke:
<grid horizontalalignment="stretch" verticalalignment="stretch" margin="5"> <grid.columndefinitions> <columndefinition width="*" /> <columndefinition width="*" /> </grid.columndefinitions> <grid.rowdefinitions> <rowdefinition height="*" /> <rowdefinition height="*" /> </grid.rowdefinitions> <rectangle grid.column="0" grid.row="0" fill="lightblue" /> <textblock grid.column="0" grid.row="0" text="(0,0)" /> <rectangle grid.column="1" grid.row="0" fill="lightyellow" /> <textblock grid.column="1" grid.row="0" text="(1,0)" /> <rectangle grid.column="0" grid.row="1" fill="lightyellow" /> <textblock grid.column="0" grid.row="1" text="(0,1)" /> <rectangle grid.column="1" grid.row="1" fill="lightblue" /> <textblock grid.column="1" grid.row="1" text="(1,0)" /> </grid>
that can, instance, give checkerboard pattern:
this no means comprehensive answer - fill book. meant show there many ways asking, , there pretty quick , easy solutions if that's need.
Comments
Post a Comment