【发布时间】:2022-03-30 21:01:01
【问题描述】:
我对 WPF 依赖属性有一个奇怪的问题:
/// <summary>
/// attached property that defines if the source is a drag source
/// </summary>
public static readonly DependencyProperty IsDragSourceProperty =
DependencyProperty.RegisterAttached("IsDragSource",
typeof(bool?),
typeof(DragDropBehaviour),
new PropertyMetadata(null,
new IsDragSourceBehaviour().PropertyChangedHandler));
当我尝试在我的 XAML 窗口中使用它时,它给了我卷线。
<ListBox IsSynchronizedWithCurrentItem="True"
AllowDrop="False"
ItemsSource="{Binding Objects, Mode=TwoWay}"
i:DragDropBehaviour.DragDropHandler="{Binding}"
i:DragDropBehaviour.IsDragSource="True" Grid.Column="0"/>
...声明“True”不是属性“IsDragSource”的有效值。 True 应该是类型 (bool?) 的 Dependency Property 的有效属性值。
我的错误是什么?
该应用程序运行良好,但我不喜欢 XAML 中的红色卷曲线。
【问题讨论】:
-
您是否尝试过重新构建解决方案?它会消失的。
-
是的,多次,没有帮助...
-
它需要可以为空吗?你试过
bool吗? -
您是否尝试过关闭并重新打开 XAML 文件?关闭并重新打开解决方案?在 VS 2013 之前,XAML 设计器似乎总是在缓存旧版本的程序集和/或错误消息时遇到问题。
-
请在编辑中查看上述解决方案...
标签: c# wpf xaml dependency-properties