ResourceDictionary
을 WPF UserControl Library 프로젝트 내에 생성하려고합니다. 나는 다음과 같은 스타일을 추가 할 때 :x : 사용자 정의 라이브러리에 유형이 없습니다.
The type 'x:Type' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.
내가로 X를 선언하고있다 :
<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>
을 내가 말하는 오류가
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
나는 내부 리소스 사전을 만들 때이 작동 WPF 응용 프로그램 프로젝트, UserControl Library 프로젝트에는 없습니다. 왜 그런가?
왜 그런지 알 수 없으므로 해결 방법은 {x : Type} 텍스트 즉 'TargetType = "Button"'을 제거하는 것입니다. Silverlight AFAIK에서 같은 오류가 발생합니다. – Patrick
하지만 항상 그런 것은 아닙니다. 위 스타일은 새로 생성 된 (.Net 4.0) WPF User Control Library 프로젝트의 리소스 사전에서 나에게 잘 작동합니다. – Clemens
VS2012 Professional을 사용하고 .NET 3.5 WPF 사용자 정의 라이브러리를 만듭니다. – FlyingStreudel