美文网首页
wpf 中的无效绑定

wpf 中的无效绑定

作者: ichengzi | 来源:发表于2017-06-14 17:59 被阅读26次

设置wpf绑定的跟踪级别为high,output中观察wpf的处理流程:

  • 对于一个无效的绑定,wpf尝试了5次,最后一次设置成了默认值。
  • 所以在程序中要尽量避免无效绑定
<TextBlock Text="{Binding Title, PresentationTraceSources.TraceLevel=High}" />
-------------------------------------------------------------------------------------------------------
System.Windows.Data Warning: 56 : Created BindingExpression (hash=66394201) for Binding (hash=49086616)
System.Windows.Data Warning: 58 :   Path: 'Title'
System.Windows.Data Warning: 60 : BindingExpression (hash=66394201): Default mode resolved to OneWay
System.Windows.Data Warning: 61 : BindingExpression (hash=66394201): Default update trigger resolved to PropertyChanged
System.Windows.Data Warning: 62 : BindingExpression (hash=66394201): Attach to System.Windows.Controls.TextBlock.Text (hash=41050810)

// 1
System.Windows.Data Warning: 67 : BindingExpression (hash=66394201): Resolving source 
System.Windows.Data Warning: 70 : BindingExpression (hash=66394201): Found data context element: TextBlock (hash=41050810) (OK)
System.Windows.Data Warning: 71 : BindingExpression (hash=66394201): DataContext is null
// 延迟重试
System.Windows.Data Warning: 65 : BindingExpression (hash=66394201): Resolve source deferred

// 2
System.Windows.Data Warning: 67 : BindingExpression (hash=66394201): Resolving source 
System.Windows.Data Warning: 70 : BindingExpression (hash=66394201): Found data context element: TextBlock (hash=41050810) (OK)
System.Windows.Data Warning: 71 : BindingExpression (hash=66394201): DataContext is null

// 3
System.Windows.Data Warning: 67 : BindingExpression (hash=66394201): Resolving source 
System.Windows.Data Warning: 70 : BindingExpression (hash=66394201): Found data context element: TextBlock (hash=41050810) (OK)
System.Windows.Data Warning: 71 : BindingExpression (hash=66394201): DataContext is null

// 4
System.Windows.Data Warning: 67 : BindingExpression (hash=66394201): Resolving source 
System.Windows.Data Warning: 70 : BindingExpression (hash=66394201): Found data context element: TextBlock (hash=41050810) (OK)
System.Windows.Data Warning: 71 : BindingExpression (hash=66394201): DataContext is null

// 5 - last chance
System.Windows.Data Warning: 67 : BindingExpression (hash=66394201): Resolving source  (last chance)
System.Windows.Data Warning: 70 : BindingExpression (hash=66394201): Found data context element: TextBlock (hash=41050810) (OK)
System.Windows.Data Warning: 78 : BindingExpression (hash=66394201): Activate with root item <null>
System.Windows.Data Warning: 106 : BindingExpression (hash=66394201):   Item at level 0 is null - no accessor
System.Windows.Data Warning: 80 : BindingExpression (hash=66394201): TransferValue - got raw value {DependencyProperty.UnsetValue}
System.Windows.Data Warning: 88 : BindingExpression (hash=66394201): TransferValue - using fallback/default value ''
System.Windows.Data Warning: 89 : BindingExpression (hash=66394201): TransferValue - using final value ''

相关文章

  • wpf 中的无效绑定

    设置wpf绑定的跟踪级别为high,output中观察wpf的处理流程: 对于一个无效的绑定,wpf尝试了5次,最...

  • WPF中的多绑定实现

    效果如下: 左边3个文本框信息,下面的文本框绑定上2个文本框信息

  • 基于WPF的截图工具,功能和QQ截图类似

    本项目基于WPF开发,适合于新手上手WPF,里面不涉及到太复杂的用法,都是一些基础绑定等操作。 有关于WPF或者项...

  • WPF数据绑定

    元素绑定 数据绑定最简单的形式是,源对象是WPF元素而且源属性是依赖属性。依赖项属性具有内置的更改通知支持,当在源...

  • WPF ControllTemplate Triggers小记

    WPF中,样式模板中如果定义EventTrigger事件方式实现动画。那么需要注意两点: 1、对于绑定的属性的Ev...

  • WPF/C#学习笔记.1:WPF中的布局TabControl,G

    WPF/C#学习笔记.1 WPF中的布局TabControl,Grid与GridSpliter等 WPF布局原则 ...

  • 测试WPF绑定bug

    1、低级错误:有没有绑错2、去属性那里打断点,get、set有没有进3、xaml加上twoway,UpdateSo...

  • WPF 数据绑定Binding

    自定义Binding 当为Binding设置了继承System.ComponentModel.INotifyPro...

  • WPF MVVM 动态绑定

    1.MVVM(Caliburn.Micro) 按钮绑定的两种方式 通过名称直接绑定到ViewModel中的方法...

  • WPF 绑定枚举集合

    假如存在星期名称的枚举类型: public enum Weeks { Monday, Tuesday, ...

网友评论

      本文标题:wpf 中的无效绑定

      本文链接:https://www.haomeiwen.com/subject/ffleqxtx.html