c# - WPF FlowDocument will not fill Viewbox container -
i have wpf usercontrol want load dynamic content in code using flowdocument: textblocks, bulleted lists, etc. content loaded expected. , box sizes looks fine in designer, in runtime flowdocument insists on clipping result , show part of width.
my assumption viewbox fill grid cell , inner flowdocument fill available space.
i tried set pagewidth/pageheigth of flowdocument in code no result.
any appreciated.
<grid x:name="grddisplay"> <grid.rowdefinitions> <rowdefinition height="22*"/> <rowdefinition height="*"/> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition width="*" /> </grid.columndefinitions> <viewbox x:name="viewboxcontent" grid.row="0" grid.column="0" grid.columnspan="2" horizontalalignment="left" verticalalignment="top" stretchdirection="downonly"> <flowdocumentscrollviewer verticalscrollbarvisibility="hidden" horizontalscrollbarvisibility="hidden"> <flowdocument x:name="flowdocument"> </flowdocument> </flowdocumentscrollviewer> </viewbox> <viewbox grid.row="1" grid.column="0" verticalalignment="bottom" horizontalalignment="left" stretchdirection="downonly"> <textblock x:name="txtbottom" /> </viewbox> </grid>
i got work!!
the problem lies in fact viewbox scaling based on design time size of child object. if actual size of internal child objects bigger, still report design time size actualwidth , actualheight properties. kind of confusing.
the workaround create whole content including flowdocumentscrollviewer , flowdocument in runtime. based on current available space , fill content expected.
in case purpose make simple markdown parser generate dynamic layout. implemented , working fine :)
Comments
Post a Comment