c# - Align TextBlock in Button / StackPanel correctly -
i try align textblocks
left. button should take rest of area (up picture). how can this?
this uwp / c# app.
<grid> <grid.columndefinitions> <columndefinition width="*"/> <columndefinition width="auto"/> </grid.columndefinitions> <grid.rowdefinitions> <rowdefinition/> </grid.rowdefinitions> <grid verticalalignment="center" horizontalalignment="left"> <button background="transparent" horizontalalignment="stretch"> <stackpanel horizontalalignment="left"> <textblock x:name="textblock1" textwrapping="wrap" text="name1"/> <textblock x:name="textblock2" textwrapping="wrap" text="name2" /> </stackpanel> </button> </grid> <stackpanel grid.column="1" grid.row="0" horizontalalignment="right"> <button height="50" width="50" background="transparent" click="button_click"> <image x:name="imagefavorit" source="/assets/stern/vgrau64.png"/> </button> </stackpanel> </grid>
firstly should replace columndefinitions
this:
<grid.columndefinitions> <columndefinition width="*"/> <columndefinition width="auto"/> </grid.columndefinitions>
and secondly remove horizontalalignment="left"
grid
can achieve want:
<grid verticalalignment="center"> <button background="transparent" horizontalalignment="stretch"> ...
also seems need set verticalalignment="center"
of stackpanel
too:
<stackpanel grid.column="1" grid.row="0" horizontalalignment="right" verticalalignment="center">
update: based on comment want text on left side set horizontalcontentalignment="left"
of button
:
<button background="transparent" horizontalalignment="stretch" horizontalcontentalignment="left">
Comments
Post a Comment