Compile-time conundrum<p>I asked this over in the WPF General forum and was advised to move it here (nobody could see what was wrong this code, I guess).<br/><br/>'m trying to add a style to my App.xaml file, which looks like this:</p> <p><strong>&lt;Application x:Class=&quot;WPFShowcaseApp.App&quot;<br/>    xmlns=&quot;</strong><a href="http://schemas.microsoft.com/winfx/2006/xaml/presentation"><strong><span style="color:#0033cc">http://schemas.microsoft.com/winfx/2006/xaml/presentation</span></strong></a><strong>&quot;<br/>    xmlns:x=&quot;</strong><a href="http://schemas.microsoft.com/winfx/2006/xaml"><strong><span style="color:#0033cc">http://schemas.microsoft.com/winfx/2006/xaml</span></strong></a><strong>&quot;<br/>    StartupUri=&quot;Window1.xaml&quot;&gt;<br/>    &lt;Application.Resources&gt;<br/>        &lt;Style x:Key=&quot;WackyButtonStyle&quot; TargetType=&quot;{x:Type Button}&quot;&gt;     <br/>            &lt;Setter Property=&quot;Height&quot; Value=&quot;200&quot; /&gt;      <br/>            &lt;Setter Property=&quot;Width&quot; Value=&quot;75&quot; /&gt;      <br/>            &lt;Setter Property=&quot;VerticalAlignment&quot; Value=&quot;Top&quot; /&gt;      <br/>            &lt;Setter Property=&quot;FontSize&quot; Value=&quot;11pt&quot; /&gt;    <br/>        &lt;/Style&gt;<br/>    &lt;/Application.Resources&gt;<br/>&lt;/Application&gt;</strong></p> <p>..but I'm getting a slew of err msgs. The first one is: <strong><em>&quot;The Element type 'System.Windows.Style' does not have an associated TypeConverter to parse the string '&quot;</em></strong></p> <p>...and then there's a ton like this: <strong><em>&quot;A value of type 'String' cannot be added to a collection or dictionary of type 'SetterBaseCollection'.&quot;</em></strong></p> <p>What am I missing here (conceptually or literally)?</p><hr class="sig">Delphi ancient/C# newbie© 2009 Microsoft Corporation. All rights reserved.Tue, 30 Jun 2009 14:29:52 Z815db34d-607f-4b68-a931-ea204cbebba6http://social.msdn.microsoft.com/Forums/en-US/vswpfdesigner/thread/815db34d-607f-4b68-a931-ea204cbebba6#815db34d-607f-4b68-a931-ea204cbebba6http://social.msdn.microsoft.com/Forums/en-US/vswpfdesigner/thread/815db34d-607f-4b68-a931-ea204cbebba6#815db34d-607f-4b68-a931-ea204cbebba6B. Clay Shannonhttp://social.msdn.microsoft.com/Profile/en-US/?user=B.%20Clay%20ShannonCompile-time conundrum<p>I asked this over in the WPF General forum and was advised to move it here (nobody could see what was wrong this code, I guess).<br/><br/>'m trying to add a style to my App.xaml file, which looks like this:</p> <p><strong>&lt;Application x:Class=&quot;WPFShowcaseApp.App&quot;<br/>    xmlns=&quot;</strong><a href="http://schemas.microsoft.com/winfx/2006/xaml/presentation"><strong><span style="color:#0033cc">http://schemas.microsoft.com/winfx/2006/xaml/presentation</span></strong></a><strong>&quot;<br/>    xmlns:x=&quot;</strong><a href="http://schemas.microsoft.com/winfx/2006/xaml"><strong><span style="color:#0033cc">http://schemas.microsoft.com/winfx/2006/xaml</span></strong></a><strong>&quot;<br/>    StartupUri=&quot;Window1.xaml&quot;&gt;<br/>    &lt;Application.Resources&gt;<br/>        &lt;Style x:Key=&quot;WackyButtonStyle&quot; TargetType=&quot;{x:Type Button}&quot;&gt;     <br/>            &lt;Setter Property=&quot;Height&quot; Value=&quot;200&quot; /&gt;      <br/>            &lt;Setter Property=&quot;Width&quot; Value=&quot;75&quot; /&gt;      <br/>            &lt;Setter Property=&quot;VerticalAlignment&quot; Value=&quot;Top&quot; /&gt;      <br/>            &lt;Setter Property=&quot;FontSize&quot; Value=&quot;11pt&quot; /&gt;    <br/>        &lt;/Style&gt;<br/>    &lt;/Application.Resources&gt;<br/>&lt;/Application&gt;</strong></p> <p>..but I'm getting a slew of err msgs. The first one is: <strong><em>&quot;The Element type 'System.Windows.Style' does not have an associated TypeConverter to parse the string '&quot;</em></strong></p> <p>...and then there's a ton like this: <strong><em>&quot;A value of type 'String' cannot be added to a collection or dictionary of type 'SetterBaseCollection'.&quot;</em></strong></p> <p>What am I missing here (conceptually or literally)?</p><hr class="sig">Delphi ancient/C# newbieTue, 23 Jun 2009 20:25:32 Z2009-06-23T20:25:32Zhttp://social.msdn.microsoft.com/Forums/en-US/vswpfdesigner/thread/815db34d-607f-4b68-a931-ea204cbebba6#957682c9-e04a-4ae9-9a4b-a7f06d6b1a95http://social.msdn.microsoft.com/Forums/en-US/vswpfdesigner/thread/815db34d-607f-4b68-a931-ea204cbebba6#957682c9-e04a-4ae9-9a4b-a7f06d6b1a95Mark Wilson-Thomashttp://social.msdn.microsoft.com/Profile/en-US/?user=Mark%20Wilson-ThomasCompile-time conundrumI cannot see anything wrong with this code, Clay.<br/><br/>I've tried adding it to a fresh WPF project's app.xaml in VS2008 SP1, and it gave me no errors and compiled just fine. <br/><br/>I even tried applying the style to a few buttons in a window1.xaml file and saw the anticipated results<br/><br/> <p><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&lt;</span></span><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">Button</span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small"> Style</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=&quot;{</span></span><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">StaticResource</span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small"> ResourceKey</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=WackyButtonStyle}&quot; &gt;</span></span><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">StyledButton</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&lt;/</span></span><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">Button</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&gt;<br/></span></span></p> <br/><br/>I think there must be some other problem at work in your project or your installation.<br/><br/>If you create a brand-new WPF project on your machine, and paste the Application.Resources block above into your app.xaml, do the same issues apply?<br/><br/>Mark<br/><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small"><font size=2 color="#a31515"><font size=2 color="#a31515"> <p> </p> </font></font></span><font size=2 color="#a31515"> <p> </p> </font></span> <p><span style="color:#0000ff;font-size:x-small"></span></p><hr class="sig">Mark Wilson-Thomas - Program Team - WPF &amp; SL Designer for Visual Studio - posts are provided 'as-is'Tue, 30 Jun 2009 01:03:37 Z2009-06-30T01:03:37Zhttp://social.msdn.microsoft.com/Forums/en-US/vswpfdesigner/thread/815db34d-607f-4b68-a931-ea204cbebba6#abc4f7eb-837c-424b-87ce-3cb1f4a55173http://social.msdn.microsoft.com/Forums/en-US/vswpfdesigner/thread/815db34d-607f-4b68-a931-ea204cbebba6#abc4f7eb-837c-424b-87ce-3cb1f4a55173B. Clay Shannonhttp://social.msdn.microsoft.com/Profile/en-US/?user=B.%20Clay%20ShannonCompile-time conundrumThanks; I added it to a new project, and there was no problem. I guess &quot;Gremlins&quot; infested the other one.<hr class="sig">Delphi ancient/C# newbieTue, 30 Jun 2009 14:29:52 Z2009-06-30T14:29:52Z