WPF RichTextBox inside DataGrid format is messed up -
i need use richtextboxes in column of datagrid. done in xaml via
<datagrid x:name="ui_tblinputs" grid.row="0" grid.column="2" grid.rowspan="3" autogeneratecolumns="false" headersvisibility="column" canusersortcolumns="false" horizontalalignment="center" itemssource="{binding inputports, mode=oneway}" selecteditem="{binding selectedinputport}" selectionmode="single" > <datagrid.columns> <datagridtextcolumn header="inputs" width="sizetocells" minwidth="50" binding="{binding name, mode=twoway}" /> <datagridtemplatecolumn header="test value" width="sizetocells" minwidth="100" > <datagridtemplatecolumn.celltemplate> <datatemplate> <richtextbox isreadonly="true" > <flowdocument> <paragraph> <run text="some text"/> </paragraph> </flowdocument> </richtextbox> </datatemplate> </datagridtemplatecolumn.celltemplate> </datagridtemplatecolumn> </datagrid.columns> </datagrid>
problem is, text inside richtextbox coming out each character on it's own line. i.e.
any thoughts why happening?
you give datagridtemplatecolumn name like: x:name="thiscolumn"
, in richtextbox set width this:
width="{binding elementname=thiscolumn, path=actualwidth}"
update: ok problem bug here work around. set "flowdocument" width richtextbox width takes width of cell.
<datagridtemplatecolumn.celltemplate> <datatemplate> <richtextbox x:name="my_rtb" isreadonly="true"> <flowdocument pagewidth="{binding elementname=my_rtb, path=actualwidth}"> <paragraph> <run text="some text"/> </paragraph> </flowdocument> </richtextbox> </datatemplate> </datagridtemplatecolumn.celltemplate>
Comments
Post a Comment