Compile-time conundrum
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).
'm trying to add a style to my App.xaml file, which looks like this:<Application x:Class="WPFShowcaseApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Window1.xaml">
<Application.Resources>
<Style x:Key="WackyButtonStyle" TargetType="{x:Type Button}">
<Setter Property="Height" Value="200" />
<Setter Property="Width" Value="75" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="FontSize" Value="11pt" />
</Style>
</Application.Resources>
</Application>..but I'm getting a slew of err msgs. The first one is: "The Element type 'System.Windows.Style' does not have an associated TypeConverter to parse the string '"
...and then there's a ton like this: "A value of type 'String' cannot be added to a collection or dictionary of type 'SetterBaseCollection'."
What am I missing here (conceptually or literally)?
Delphi ancient/C# newbie
Réponses
- I cannot see anything wrong with this code, Clay.
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.
I even tried applying the style to a few buttons in a window1.xaml file and saw the anticipated results
<Button Style="{StaticResource ResourceKey=WackyButtonStyle}" >StyledButton</Button>
I think there must be some other problem at work in your project or your installation.
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?
Mark
Mark Wilson-Thomas - Program Team - WPF & SL Designer for Visual Studio - posts are provided 'as-is'- Marqué comme réponseB. Clay Shannon mardi 30 juin 2009 14:29
Toutes les réponses
- I cannot see anything wrong with this code, Clay.
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.
I even tried applying the style to a few buttons in a window1.xaml file and saw the anticipated results
<Button Style="{StaticResource ResourceKey=WackyButtonStyle}" >StyledButton</Button>
I think there must be some other problem at work in your project or your installation.
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?
Mark
Mark Wilson-Thomas - Program Team - WPF & SL Designer for Visual Studio - posts are provided 'as-is'- Marqué comme réponseB. Clay Shannon mardi 30 juin 2009 14:29
- Thanks; I added it to a new project, and there was no problem. I guess "Gremlins" infested the other one.
Delphi ancient/C# newbie

