【发布时间】:2011-04-09 05:14:17
【问题描述】:
我创建了一个 AttachedProperty,它在测试项目中工作得很好,但在更大的项目中,附加属性在一个项目中定义并在其他项目中使用我得到这个奇怪的错误:
System.Windows.Markup.XamlParseException 发生 消息=无法在属性“IsTextDragSource”中转换字符串“False” 到“System.Boolean”类型的对象。 标记文件中的对象“System.Windows.HierarchicalDataTemplate”出错 'ServerMonitoringModule; 组件/视图/列表/jobbrowser/jobreportdetailsview.xaml' 第 147 行位置 84。Source=PresentationFramework LineNumber=147 LinePosition=84 NameContext=资源 堆栈跟踪: 在 System.Windows.Markup.XamlParseException.ThrowException(字符串消息,异常 innerException,Int32 lineNumber,Int32 linePosition,Uri baseUri,XamlObjectIds currentXamlObjectIds,XamlObjectIds contextXamlObjectIds,类型 objectType) 在 System.Windows.Markup.XamlParseException.ThrowException(ParserContext parserContext,Int32 lineNumber,Int32 linePosition,字符串消息,异常 innerException) 在 System.Windows.Markup.XamlTypeMapper.ParseProperty(对象 targetObject,类型 propType,字符串 propName,对象 dpOrPiOrFi,ITypeDescriptorContext typeContext,ParserContext parserContext,字符串值,Int16 converterTypeId) 在 System.Windows.Markup.OptimizedTemplateContent.ParseDependencyProperty(字符串 attribValue,Int16 attributeId,Int16 converterTypeId,DependencyProperty&dp,Object&propertyValue) 在 System.Windows.Markup.OptimizedTemplateContent.LookForShareableRecord(BamlRecord bamlRecord,DependencyProperty& dp,Object& dpValue) 在 System.Windows.Markup.OptimizedTemplateContent.ReadPotentiallyShareableRecord(BamlRecord bamlRecord) 在 System.Windows.Markup.OptimizedTemplateContent.ReadRecord(BamlRecord bamlRecord) ...报错行:
<TextBlock Text="{Binding Text}" dscb:TextDragHelper.IsTextDragSource="False"/>
以及属性的定义:
public class TextDragHelper : DependencyObject
{
public static readonly DependencyProperty IsTextDragSourceProperty =
DependencyProperty.RegisterAttached("IsTextDragSource",
typeof(bool), typeof(TextDragHelper),
new FrameworkPropertyMetadata(OnDragSourceAdvisorChanged));
有没有人遇到过这种情况或有解决办法?
【问题讨论】:
标签: c# wpf xaml attached-properties