c# - Application crashing when using <Run Text={Binding ...}/> with certain properties in a textblock -
i using <run text={binding ...}/>
inside textblock
in order concatenate 2 strings (one hard coded, other 1 binding expression on property). being done in datatemplate
:
<resourcedictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <datatemplate x:key="marketorderdatatemplate"> <grid> <grid.rowdefinitions> <rowdefinition height="auto"/> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition width="auto"/> <columndefinition width="auto"/> <columndefinition width="30*"/> <columndefinition width="auto"/> <columndefinition width="70*"/> </grid.columndefinitions> <!-- item icon todo: add icon--> <image grid.column="0" margin="10,0,10,0" stretch="fill" source="../../images/thumb_icon-mineral-protoss.png" /> <separator grid.column="1" style="{staticresource {x:static toolbar.separatorstylekey}}" /> <!-- item information --> <grid grid.column="2" margin="10,0,10,0" horizontalalignment="center"> <grid.rowdefinitions> <rowdefinition height="33*"/> <rowdefinition height="33*"/> <rowdefinition height="33*"/> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition width="*"/> </grid.columndefinitions> <textblock grid.row="0"> <run text="item name : "/> <run text="{binding item.itemname}"/> </textblock> <textblock grid.row="1"> <run text="item id : "/> <run text="{binding item.itemid}"/> </textblock> <textblock grid.row="2"> <run text="item type : "/> <run text="{binding item.itemtype}"/> </textblock> </grid> <separator grid.column="3" style="{staticresource {x:static toolbar.separatorstylekey}}" /> <!-- market order information --> <grid grid.column="4" margin="10,0,10,0" horizontalalignment="center"> <grid.rowdefinitions> <rowdefinition height="33*"/> <rowdefinition height="33*"/> <rowdefinition height="33*"/> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition width="*"/> </grid.columndefinitions> <textblock grid.row="0"> <run text="market order id : "/> <run text="{binding orderid}"/> </textblock> <textblock grid.row="1"> <run text="price : "/> <run text="{binding price}"/> </textblock> <textblock grid.row="2"> <run text="volume remaining : "/> <run text="{binding volumeremaining}"/> </textblock> </grid> </grid> </datatemplate> </resourcedictionary>
this works in item information part of datatemplate
(with bindings on item.itemname
, item.itemid
, item.itemtype
) without problems. when try same market order information part of datatemplate
(with bindings on orderid
, price
, volumeremaining
) though, makes application crash reason.
it works if set text
property on textblock
same binding expression, not know why makes application crash <run text={binding ...}/>
syntax on market order info part?
you did not show view model or error can suspect it's because property read-only , run
default bind both ways. change binding oneway
<run text="{binding volumeremaining, mode=oneway}"/>
Comments
Post a Comment