c# - Styling a TreeList cell Exception -


i'm trying style cells in listtree based on value of cell. every time run code following exception, , can't figure out going wrong.

an unhandled exception of type 'system.windows.markup.xamlparseexception' occurred in presentationframework.dll

c# value checking

public class statusstyle : markupextension, ivalueconverter     {          public style red { get; set; }         public style green { get; set; }         public style orange { get; set; }         public style gray { get; set; }         public style blue { get; set; }           #region ivalueconverter members          public object convert(object value, system.type targettype,                     object parameter, system.globalization.cultureinfo culture)         {             if (value.tostring().equals("trade"))             {                 return red;             }              return null;         }          public object convertback(object value, system.type targettype,                     object parameter, system.globalization.cultureinfo culture)         {             throw new system.notimplementedexception();         }          #endregion          public override object providevalue(system.iserviceprovider serviceprovider)         {             return this;         }     } 

wpf code

<window         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"         xmlns:local="clr-namespace:loghunter"         xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"         xmlns:dxt="http://schemas.devexpress.com/winfx/2008/xaml/grid" x:class="loghunter.window1"         mc:ignorable="d"         title="window1" height="750" width="750">     <grid>           <grid.resources>             <local:statusstyle x:key="statusstyle">                 <local:statusstyle.red>                     <style targettype="dxt:cellcontentpresenter">                         <setter property="background" value="green"/>                     </style>                 </local:statusstyle.red>             </local:statusstyle>         </grid.resources>          <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"                                      cellstyle="{staticresource statusstyle}"/>                 <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>      </grid> </window> 

here lot of possibilities it:

1) use formatconditions

            <dxg:treelistview name="treelistview1" autowidth="true" keyfieldname="id" parentfieldname="parentid">                 <dxg:treelistview.formatconditions>                     <dxg:formatcondition fieldname="status" expression="[status] = 'trade'" predefinedformatname="lightredfill"/>                 </dxg:treelistview.formatconditions>             </dxg:treelistview> 

predefined formats can find here: https://documentation.devexpress.com/#wpf/devexpressxpfgridtableview_predefinedformatstopic

2) objecttoobject converter devexpress

<window     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     xmlns:setcellstyle="clr-namespace:setcellstyle"     xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"     xmlns:dxgt="http://schemas.devexpress.com/winfx/2008/xaml/grid/themekeys"     xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"     x:class="setcellstyle.mainwindow"     title="mainwindow" height="350" width="525"> <grid>     <grid.resources>         <dxmvvm:objecttoobjectconverter x:key="stringtocolorconverter">             <dxmvvm:mapitem source="trade" target="#800080"/>             <dxmvvm:mapitem source="notrade" target="red"/>         </dxmvvm:objecttoobjectconverter>         <style x:key="conditionalcellstyle" basedon="{staticresource {dxgt:gridrowthemekey resourcekey=lightweightcellstyle}}" targettype="{x:type dxg:lightweightcelleditor}">             <setter property="background" value="{binding path=value, converter={staticresource stringtocolorconverter}}"/>         </style>     </grid.resources>      <dxg:treelistcontrol x:name="treelistcontrol">         <dxg:treelistcontrol.columns>             <dxg:treelistcolumn fieldname="clientid" header="heirarchy" readonly="true"/>             <dxg:treelistcolumn fieldname="status" cellstyle="{staticresource conditionalcellstyle}" readonly="true"/>         </dxg:treelistcontrol.columns>         <dxg:treelistcontrol.view>             <dxg:treelistview name="treelistview1" autowidth="true" keyfieldname="id" parentfieldname="parentid">             </dxg:treelistview>         </dxg:treelistcontrol.view>     </dxg:treelistcontrol>  </grid> 

3) think, here lot more solutions dont know


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -