c# - Clone a WPF element with a Setter -


in wpf application, have tabcontrol tabitems :

<tabitem.header>     <stackpanel orientation="horizontal">         <textblock name ="tabheader"/>         <image margin="7,0,0,0">             <image.style>                 <style>                     <setter property="image.source" value="pictures/croixrouge.png"/> // no error without line                          </style>             </image.style>         </image>     </stackpanel> </tabitem.header> 

and clone tabitem add 1 in tabcontrol following function :

tabitem ti = (tabitem)_tabcontrollist.items.getitemat(_tabcontrollist.items.count - 1); tabitem ticloned= trycloneelement<tabitem>(ti);  private static t trycloneelement<t>(t orig) {     try     {         string s = system.windows.markup.xamlwriter.save(orig); // error : impossible serialize non-public type 'system.windows.media.imaging.bitmapframedecode'          stringreader stringreader = new stringreader(s);          xmlreader xmlreader = xmltextreader.create(stringreader, new xmlreadersettings());         xmlreadersettings sx = new xmlreadersettings();          object x = system.windows.markup.xamlreader.load(xmlreader);         return (t)x;     }     catch     {         return (t)((object)null);     }  } 

why error appear ? when place image :

<tabitem.header>     <stackpanel orientation="horizontal">         <textblock name ="tabheader"/>         <image margin="7,0,0,0" source="pictures/croixrouge.png"/>     </stackpanel> </tabitem.header> 

i have no problem. have use <setter...> change image source on mouse hover.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -