I'm trying to create a ResourceDictionary
inside a WPF UserControl Library project. When I add the following style:
<Style TargetType="{x:Type Button}">
<Setter Property="Background" Value="{StaticResource ResourceKey=GreyBrush}"/>
<Setter Property="BorderBrush" Value="{StaticResource ResourceKey=LightBlueBrush}"/>
<Setter Property="BorderThickness" Value="1"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{StaticResource ResourceKey=OrangeBrush}"/>
</Trigger>
<EventTrigger RoutedEvent="Click">
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="Background.Color" To="{StaticResource ResourceKey=LightOrange}" Duration="0:0:.1"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Style.Triggers>
</Style>
I get an error saying:
The type 'x:Type' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.
I am declaring x as:
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
This works when I create a resource dictionary inside a WPF application project, but not inside a UserControl Library project. Any idea why?
This happened to me when I was writing an IE Extension and wanted to create WPF User Controls. Since the project was not originally a WPF project there was no reference to System.Xaml, adding said reference fixed the issue.
Had the same looking issue in my project. I've solved it by switching Target Framework from .NET 3.0 to 4.0.
I have to disagree, here's my decalaration from a UserControl that does work.
<UserControl x:Class="RedGreenRefactor.View.TestResultsGraph"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Is there any chance that the error is telling you exactly what is wrong? Have you got all the assemblies referenced that you need?
Creating a new WPF application I get the following.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With