windows - Using PathIcon from resources results in XamlParseException -


universal store project 8.1 here.

i have pathicon declared in resourcedictionary this:

<pathicon      x:key="phoneicon"      data="f0 m22,22z m0,0z m17.4,22.533333c19.111111,25.955556,22.044444,28.766667,25.466667,30.6l28.155556,27.911111c28.522222,27.544444 29.011111,27.422222 29.377778,27.666667 30.722222,28.155556 32.188889,28.4 33.777778,28.4 34.511111,28.4 35,28.888889 35,29.622222l35,33.777778c35,34.511111 34.511111,35 33.777778,35 22.288889,35 13,25.711111 13,14.222222 13,13.488889 13.488889,13 14.222222,13l18.5,13c19.233333,13 19.722222,13.488889 19.722222,14.222222 19.722222,15.688889 19.966667,17.155556 20.455556,18.622222 20.577778,18.988889 20.455556,19.477778 20.211111,19.844444l17.4,22.533333 17.4,22.533333z"     /> 

i can resource in code behind this:

pathicon icon1 = null; object resource; if (application.current.resources.trygetvalue("phoneicon", out resource)) {   icon1 = resource pathicon; }; 

alternatively, can create (avoiding querying resource dictionary):

var icon2 = xamlreader.load(   @"<pathicon          xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""          data=""f0 m22,22z m0,0z m17.4,22.533333c19.111111,25.955556,22.044444,28.766667,25.466667,30.6l28.155556,27.911111c28.522222,27.544444 29.011111,27.422222 29.377778,27.666667 30.722222,28.155556 32.188889,28.4 33.777778,28.4 34.511111,28.4 35,28.888889 35,29.622222l35,33.777778c35,34.511111 34.511111,35 33.777778,35 22.288889,35 13,25.711111 13,14.222222 13,13.488889 13.488889,13 14.222222,13l18.5,13c19.233333,13 19.722222,13.488889 19.722222,14.222222 19.722222,15.688889 19.966667,17.155556 20.455556,18.622222 20.577778,18.988889 20.455556,19.477778 20.211111,19.844444l17.4,22.533333 17.4,22.533333z""          />" ) pathicon; 

both ways me pathicon instance looks fine (icon1 , icon2 seem identical).

debug.writeline(    "{0} equals {1}: {2}",   icon1.data.bounds, icon2.data.bounds,   icon1.data.bounds.equals(icon2.data.bounds) ); // outputs 13,13,22,22 equals 13,13,22,22: true 

i'm trying use icon appbarbutton:

        somecommandbar.primarycommands.add(new appbarbutton(){           label = "label",           icon = icon1 or icon2,           command = somecommand         });     

the problem is: when use icon2 (created xamlreader), works fine, when use icon1 (fetched resourcedictionary), xamlparseexception:

"failed assign property '%0'. [line: 0 position: 0]" 

i'd appreciate ideas why may happening.

update

this doesn't work either (the error same above):

<page.bottomappbar>     <commandbar>         <appbarbutton             label="test"             icon="{staticresource phoneicon}"             />     </commandbar> </page.bottomappbar> 

so, guess, there's no way can work @ all. doesn't work static resource in place. guess i'll have store string resources icons , xmlreader.load() them every time, chris w. suggested in comments.

however

the following work reason (not it's useful in way):

  pathicon icon1 = null;   object resource;   if (application.current.resources.trygetvalue("phoneicon", out resource)) {     icon1 = resource pathicon;     // if resource removed dictionary before used,     // no exception thrown.     foreach(var m in application.current.resources.mergeddictionaries) {       if (m.containskey("phoneicon")) {         m.remove("phoneicon"); //       }     }   }; 

i find data path far more complex in declarative xaml of resources implicit converter of data property. since have working data property, let visual studio work. open properties dialog in xaml designer , click small right square (it black @ first) net data property , select "make resource". resulting wizard guide you, , see data string converted component parts , work way want after this.

enter image description here

best of luck.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -