c# - Changing a Setter Value Dynamically in WPF -


i trying change setter value dynamically. though successful partially, stuck progressing further. attempt change column colours of wpf toolkit generated column chart depending on series. used static member of separate class set color of background property of column data point. in way assigned color gets set columns regardless of being different series. following useful code spinets:

column datapoint style defined following xaml:

<local:mybackcolor x:key="mybackresource"></local:mybackcolor> <style x:key="infocruiseraquacolumn" targettype="dvc:columndatapoint">     <setter property="background" value="{binding source={staticresource mybackresource}, path= mybackcolor}"/>     <setter property="borderbrush" value="transparent" />     <setter property="borderthickness" value="1" />... 

class sets color:

public class mybackcolor {     private static string _mybackcolor;       public static string mybackcolor     {         { return _mybackcolor; }          set         {             _mybackcolor = value;             //helpers.invokepropertychanged(propertychanged, this, "grade");         }     } } 

setting color in code:

 //changing column color                 mybackcolor.mybackcolor = colorvalue;                  mystyle = (style)findresource("infocruiseraquacolumn");                  columnseries mycolumnseries = new columnseries();                 mycolumnseries.title = "experience";                  mycolumnseries.itemssource = seriesdata;                  mycolumnseries.independentvaluebinding = new binding("key");                 mycolumnseries.dependentvaluebinding = new binding("value");                 mycolumnseries.background = new solidcolorbrush(colors.black);                   mycolumnseries.datapointstyle = mystyle;                  mcchart.series.add(mycolumnseries); 

any appreciated.

i think need both notifypropertychange (why commented out?) , make background dynamicresource:

<setter property="background"        value="{binding source={dynamicresource mybackresource}, path= mybackcolor}"/> 

after comments:

your current solution not going work. when execute

   mycolumnseries.datapointstyle = mystyle; 

you storing reference style, not copy. series still share same style (the last one).

you'll have use (incomplete answer ahead):

mycolumnseries.datapointstyle = new style(); mycolumnseries.datapointstyle.background = ... 

or maybe can set color of series , use shared style other properties.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -