Linking WPF object to C# styling -
i'm using treelist
control devexpress. i'm trying color in cells based on value. got code structure here. however, c# function not seem linked wpf object. how can link handles treelist.nodecellstyle
event?
sample code
private void treelist1_nodecellstyle(object sender, getcustomnodecellstyleeventargs e) { // modify appearance settings used paint "budget" column's cells // values greater 500,000. if (e.column.fieldname != "budget") return; if (convert.toint32(e.node.getvalue(e.column.absoluteindex)) > 500000) { e.appearance.backcolor = color.fromargb(80, 255, 0, 255); e.appearance.forecolor = color.white; e.appearance.font = new font(e.appearance.font, fontstyle.bold); } }
sample wpf
<dxt:treelistcontrol name="treelist"> <dxt:treelistcontrol.columns> <dxt:treelistcolumn fieldname="clientid" header="heirarchy"/> <dxt:treelistcolumn fieldname="instrumentid" /> <dxt:treelistcolumn fieldname="orderid" /> <dxt:treelistcolumn fieldname="status" /> <dxt:treelistcolumn fieldname="openposition" /> <dxt:treelistcolumn fieldname="execposition" /> <dxt:treelistcolumn fieldname="cumopenposition" /> <dxt:treelistcolumn fieldname="cumexecposition" /> <dxt:treelistcolumn fieldname="transactiontime" /> <dxt:treelistcolumn fieldname="logtime" /> </dxt:treelistcontrol.columns> <dxt:treelistcontrol.view> <dxt:treelistview name="treelistview1" autowidth="true" keyfieldname="id" parentfieldname="parentid" /> </dxt:treelistcontrol.view> </dxt:treelistcontrol>
you can use conditional formatting.
here example in wpf
:
<dxt:treelistcontrol.view> <dxt:treelistview name="treelistview1" autowidth="true" keyfieldname="id" parentfieldname="parentid"> <dxt:treelistview.formatconditions> <dxt:formatcondition fieldname="budget" expression="[budget] > 500000"> <dx:format foreground="white" background="#50ff00ff" fontweight="bold"/> </dxt:formatcondition> </dxt:treelistview.formatconditions> </dxt:treelistview> </dxt:treelistcontrol.view>
the same in c#
:
treelistcontrol1.view.formatconditions.add(new formatcondition() { fieldname = "budget", expression = "budget > 500000", format = new format() { background = new solidcolorbrush(color.fromargb(80, 255, 0, 255)), foreground = brushes.white, fontweight = fontweights.bold } });
Comments
Post a Comment