c# - WPF: Order of stretch sizing -
i'm creating modal dialog window contains 3 essential parts: textblock containing instructions, contentcontrol dialog panel, , contentcontrol dialog buttons. each of these parts contained in separate grid row.
i have specific constraints when comes how dialog should sized. issue i'm having instructions textblock. want instructions wide contentcontrol dialog panel. instructions should wrap , grow vertically needed. should instructions not able grow vertically, should begin grow horizontally.
getting instructions width of contentcontrol , grow vertically simple. part can't seem figure out how grow horizontally when out of vertical space. initial thought create class extends textblock , override measureoverride. however, method sealed. currently, i'm playing idea of have dialog window override measureoverride calculate available size instructions block.
am missing simpler way of accomplishing this? have better ideas this? messing measureoverride seems lot of work.
here sample code give general idea of how dialog laid out:
<window x:class="dialogs.dialogwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:name="dialogwindow" showintaskbar="false" windowstyle="none" allowstransparency="true" background="transparent" resizemode="noresize" sizetocontent="widthandheight" windowstartuplocation="centerscreen"> <border style="{staticresource windowborderstyle}" margin="15"> <grid> <grid.rowdefinitions> <rowdefinition height="auto"/> <rowdefinition height="auto"/> <rowdefinition height="auto"/> </grid.rowdefinitions> <textblock margin="25,5" verticalalignment="top" horizontalalignment="left" text="{binding instructions}" textwrapping="wrap" width="{binding elementname=panelcontentcontrol, path=actualwidth, mode=oneway}"/> <contentcontrol x:name="panelcontentcontrol" grid.row="1" margin="25,5" content="{binding panelcontent}"/> <contentcontrol x:name="buttonscontentcontrol" grid.row="2" horizontalalignment="right" verticalalignment="center" margin="25,5" content="{binding buttonscontent}"/> </grid> </border> </window>
it appears if want create new panel
or derive existing 1 take place of grid
. panel
responsible laying out content should go way instead of messing window.measureoverride
.
how want textblock
grow horizontally , why want this? growing horizontally want grow window too?
Comments
Post a Comment