.net - WPF can't find simple resources anymore -


i have simple demo application use testing purposes. added resource dictionary , wpf fails find resources @ runtime. visual studio regards resources fine , shows styles in visual designer, when application run, xamlparseexception saying resource not found. code nothing else other working applications, can't find difference. what's problem that?

here's example of resource dictionary appresources.xaml:

<resourcedictionary     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">      <!-- there need @ least 2 styles if startupuri not used. -->     <!-- see http://bengribaudo.com/blog/2010/08/19/106/bug-single-application-resources-entry-ignored -->     <style x:key="__unused"/>      <style x:key="infolabelstyle" targettype="textblock">         <setter property="foreground" value="green"/>     </style> </resourcedictionary> 

referenced app.xaml:

<application     x:class="demoapp.app"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">      <application.resources>         <resourcedictionary>             <resourcedictionary.mergeddictionaries>                 <resourcedictionary source="/resources/appresources.xaml"/>                 <resourcedictionary source="/resources/appresources2.xaml"/>             </resourcedictionary.mergeddictionaries>         </resourcedictionary>     </application.resources> </application> 

and mainwindow.xaml fails run because of "infolabelstyle" not found, while text appears green in designer:

<window     x:class="demoapp.view.mainwindow"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     title="demoapp"     height="150" width="525">      <grid>         <textblock             margin="12"             style="{staticresource infolabelstyle}"             text="info"/>     </grid> </window> 

you can find full project source code here: http://unclassified.de/tmp/demoapp.zip

add call application's initializecomponent method in main entry point:

[stathread] public static void main() {     appdomain.currentdomain.unhandledexception += currentdomain_unhandledexception;     taskscheduler.unobservedtaskexception += taskscheduler_unobservedtaskexception;      var app = new app();     app.initializecomponent();     app.run(); } 

what initializecomponent() do, , how work in wpf?

how write custom main method wpf application?


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -