gpt4 book ai didi

c# - x :Type not found in user control library

转载 作者:可可西里 更新时间:2023-11-01 03:13:15 26 4
gpt4 key购买 nike

我正在尝试在 WPF 用户控件库项目中创建一个 ResourceDictionary。当我添加以下样式时:

<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>

我收到一条错误消息:

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 声明为:

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

当我在 WPF 应用程序项目中而不是在 UserControl 库项目中创建资源字典时,这会起作用。知道为什么吗?

最佳答案

当我编写 IE 扩展并想要创建 WPF 用户控件时,这发生在我身上。由于该项目最初不是 WPF 项目,因此没有对 System.Xaml 的引用,添加该引用解决了该问题。

关于c# - x :Type not found in user control library,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12606304/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com