我们用wndbg调试时,很多时候需要查看某个控件的依赖属性值。
**比如:我们查看DataGridColumnHeader的Content依赖属性**
****
**1.我们用到的windbg的命令有:!do, !da -details, .formats **
**2.利用!do查看依赖对象的成员变量, 找到具体依赖属性的地址**
0:000> !do 00000000039a71d8
Name: System.Windows.Controls.Primitives.DataGridColumnHeader
MethodTable: 000007fee7e58090
EEClass: 000007fee7885bd8
Size: 384(0x180) bytes
File: C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.dll
Fields:
MT Field Offset Type VT Attr Value Name
000007fef3f2eb00 4000db0 8 ...eading.Dispatcher 0 instance 0000000002dd4e68 _dispatcher
000007fef3f3bb88 4001321 10 ...endencyObjectType 0 instance 000000000308a530 _dType
000007fef7825ac8 4001322 18 System.Object 0 instance 0000000000000000 _contextStorage
000007fef3f3e898 4001323 20 ...ctiveValueEntry[] 0 instance 00000000042efb08 _effectiveValues
000007fef7847b70 4001324 28 System.UInt32 1 instance 3680277 _packedData
000007fef3f33708 400131f 7c0 ...ependencyProperty 0 static 0000000002dd5ef0 DirectDependencyProperty
---------------------省略部分----
000007fef3f33708 40002ca 950 ...ependencyProperty 0 static 0000000002dfd820 ContentProperty
0000000000000000 40002cb 958 0 static 0000000002dfd908 HasContentPropertyKey
000007fef3f33708 40002cc 960 ...ependencyProperty 0 static 0000000002dfd948 HasContentProperty
000007fef3f33708 40002cd 968 ...ependencyProperty 0 static 0000000002dfdb00 ContentTemplateProperty
000007fef3f33708 40002ce 970 ...ependencyProperty 0 static 0000000002dfdc80 ContentTemplateSelectorProperty
**3.利用!do命令查看依赖属性的成员变量值, 比如:**
0:000> !do 0000000002dfd820
Name: System.Windows.DependencyProperty
MethodTable: 000007fef3f33708
EEClass: 000007fef3dd7550
Size: 88(0x58) bytes
File: C:\Windows\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll
Fields:
MT Field Offset Type VT Attr Value Name
000007fef7826970 400133c 8 System.String 0 instance 0000000002dfd630 _name
000007fef78282f8 400133d 10 System.Type 0 instance 0000000002d444b0 _propertyType
000007fef78282f8 400133e 18 System.Type 0 instance 0000000002dfab80 _ownerType
000007fef3f312a8 400133f 20 ....PropertyMetadata 0 instance 0000000002dfd7c0 _defaultMetadata
000007fef3f31088 4001340 28 ...dateValueCallback 0 instance 0000000000000000 _validateValueCallback
000007fef3f3e750 4001341 30 ...ndencyPropertyKey 0 instance 0000000000000000 _readOnlyKey
000007fef4194818 4001342 40 System.Int32 1 instance 4194530 _packedData
000007fef3f3e408 4001343 48 ....InsertionSortMap 1 instance 0000000002dfd868 _metadataMap
000007fef3f30fc8 4001344 38 ...erceValueCallback 0 instance 0000000000000000 _designerCoerceValueCallback
000007fef7825ac8 400133b 808 System.Object 0 static 0000000002d72000 UnsetValue
000007fef3f3c6c0 4001345 800 ...ty, WindowsBase]] 1 static 0000000012d5bb10 RegisteredPropertyList
000007fef7831c38 4001346 810 ...ections.Hashtable 0 static 0000000002d6f3d8 PropertyFromName
000007fef782c858 4001347 5c8 System.Int32 1 static 868 GlobalIndexCount
000007fef7825ac8 4001348 818 System.Object 0 static 0000000002d6f430 Synchronized
000007fef78282f8 4001349 820 System.Type 0 static 0000000002d68808 NullableType
**4.利用.formats 得到依赖属性, 分2步**
1)利用.formats 0n得到_packedData十六进制
2) 去掉高位,Decimal描述的就是依赖属性在依赖对象中的存储索引
如下:
0:000> .formats 0n4194530
Evaluate expression:
Hex: 00000000`004000e2
Decimal: 4194530
Octal: 0000000000000020000342
Binary: 00000000 00000000 00000000 00000000 00000000 01000000 00000000 11100010
Chars: .....@..
Time: Wed Feb 18 21:08:50 1970
Float: low 5.87779e-039 high 0
Double: 2.07237e-317
0:000> .formats 00e2
Evaluate expression:
Hex: 00000000`000000e2
Decimal: 226
Octal: 0000000000000000000342
Binary: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 11100010
Chars: ........
Time: Thu Jan 01 08:03:46 1970
Float: low 3.16693e-043 high 0
Double: 1.11659e-321
可知ContentProperty依赖属性在DataGridColumnHeader中的索引为226
**5. 根据第4步的index,从第2步依赖对象的_effectiveValues 得到依赖属性的具体值,分3步:**
1)利用!da -details 查看_effectiveValues 数组所有元素的值
2)查看每个元素,根据_propertyIndex (即第4步得到的Decimal值)确定依赖属性
3)利用!do命令查看元素的_value成员的值
比如:
0:000> !da -details 00000000042efb08
Name: System.Windows.EffectiveValueEntry[]
MethodTable: 000007fef3f3e898
EEClass: 000007fef3e0c8a0
Size: 408(0x198) bytes
Array: Rank 1, Number of elements 24, Type VALUETYPE
Element Methodtable: 000007fef3f36120
[0] 00000000042efb18
Name: System.Windows.EffectiveValueEntry
MethodTable: 000007fef3f36120
EEClass: 000007fef3dd8c90
Size: 32(0x20) bytes
File: C:\Windows\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll
Fields:
MT Field Offset Type VT Attr Value Name
000007fef7825ac8 400136e 0 System.Object 0 instance 0000000002e1c5d8 _value
000007fef7830940 400136f 8 System.Int16 1 instance 3 _propertyIndex
000007fef41949d0 4001370 a System.Int16 1 instance 2 _source
--------------------------------省略部分------------------------------
[15] 00000000042efc08
Name: System.Windows.EffectiveValueEntry
MethodTable: 000007fef3f36120
EEClass: 000007fef3dd8c90
Size: 32(0x20) bytes
File: C:\Windows\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll
Fields:
MT Field Offset Type VT Attr Value Name
000007fef7825ac8 400136e 0 System.Object 0 instance 00000000042efca0 _value
000007fef7830940 400136f 8 System.Int16 1 instance 226 _propertyIndex
000007fef41949d0 4001370 a System.Int16 1 instance 65 _source
可知ContentProperty为_effectiveValues的第16个元素, 其值存储在_value中
0:000> !do 00000000042efca0
Name: System.Windows.ModifiedValue
MethodTable: 000007fef3f40d58
EEClass: 000007fef3e0d000
Size: 48(0x30) bytes
File: C:\Windows\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll
Fields:
MT Field Offset Type VT Attr Value Name
000007fef7825ac8 4001387 8 System.Object 0 instance 0000000000000000 _baseValue
000007fef7825ac8 4001388 10 System.Object 0 instance 0000000000000000 _expressionValue
000007fef7825ac8 4001389 18 System.Object 0 instance 0000000000000000 _animatedValue
000007fef7825ac8 400138a 20 System.Object 0 instance 0000000002d93618 _coercedValue
**6.根据第5步中的成员_coercedValue得到依赖属性的具体值,大功告成!**
0:000> !do 0000000002d93618
Name: System.String
MethodTable: 000007fef7826970
EEClass: 000007fef73aeec8
Size: 36(0x24) bytes
File: C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll
String: 导入数据源
Fields:
MT Field Offset Type VT Attr Value Name
000007fef782c858 40000ed 8 System.Int32 1 instance 5 m_stringLength
000007fef782b398 40000ee c System.Char 1 instance 5bfc m_firstChar
000007fef7826970 40000ef 10 System.String 0 shared static Empty
>> Domain:Value 00000000007f85a0:0000000002d41420 <<
- 前言
- win32与WPF的混合编程
- WPF: 一个可以用StoryBoard动态改变Grid行宽/列高的类
- MFC中调用WPF教程
- Expression Blend操作: 使用behavior来控制Storyboard
- WPF DatePicker 的textbox的焦点
- WPF 使用MultiBinding ,TwoWay ,ValidationRule ,需要注意的事项
- WPF TreeView 后台C#选中指定的Item, 需要遍历
- WPF GridViewColumn Sort DataTemplate
- DataGridColum的bug
- WPF Get Multibinding Expression, Update Source,
- WPF 后台触发 Validate UI‘s Element
- WPF ValidationRule 触发ErrorTemplate 的注意事项
- WPF DelegateCommand CanExecute
- WPF TextBox PreviewTextInput handle IME (chinese)
- No overload for &#39;OnStartup&#39; matches delegate &#39;System.Windows.StartupEventHandler&#39;
- WPF error: does not contain a static &#39;Main&#39; method suitable for an entry point
- WPF GridView中的CellTemplate失效的原因
- DataGrid 显示选中的item
- 如何得到WPF中控件绑定的EventTrigger
- 选中DataGrid的Cell而不是row
- ContextMenu的自定义
- 输入框只能输入英文
- TextBox的OnTextboxChanged事件里对Text重新赋值带中文, 导致崩溃
- DataGrid当列宽超出当前宽度时,没有数据也恒有滚动条
- wpf如何获取control template里的元素
- Set connectionId threw an exception.
- WPF中Visible设为Collapse时,VisualTreeHelper.GetChildrenCount为0
- XAML 编码规范 (思考)
- 如何为现有控件的DependencyProperty添加Value Changed事件?
- TreeView滚动TreeViewItem
- 为BindingList添加Sort
- WPF Background的设置有坑
- 自定义Panel中添加依赖属性需要注意的问题
- TextBlock截断字符显示为....
- DataGrid 支持字符截断显示
- TreeView控件实践
- WPF如何更改系统控件的默认高亮颜色 (Highlight brush)
- ViewModel中C# Property自动添加OnPropertyChanged处理的小工具, 以及相应Python知识点
- WPF中Xaml编译正常而Designer Time时出错的解决办法
- 关于Snoop的用法
- wpf中为DataGrid添加checkbox支持多选全选
- WPF中DataGrid控件的过滤(Filter)性能分析及优化
- wpf控件提示Value ‘’ can not convert
- DropShadowEffect导致下拉框控件抖动
- 再论WPF中的UseLayoutRounding和SnapsToDevicePixels
- WPF案例:如何设计历史记录查看UI
- WPF案例:如何设计搜索框(自定义控件的原则和方法)
- WPF基本概念入门
- WPF开发中Designer和码农之间的合作
- 聊聊WPF中的Dispatcher
- 聊聊WPF中字体的设置
- Bug:DataGridCell的显示不完整
- WPF中ToolTip的自定义
- WPF中ItemsControl绑定到Google ProtocolBuffer的结构体时的性能问题
- TreeView的性能问题
- Xaml中string(字符串)常量的定义以及空格的处理
- 依赖属性
- WPF中的CheckBox的_ (underscore / 下划线)丢失
- WPF错误:必须使“Property”具有非 null 值。
- WPF中ItemsControl应用虚拟化时找到子元素的方法
- WPF毫秒级桌面时钟的实现-C#中Hook(钩子)的应用
- KB2464222导致IsNonIdempotentProperty方法找不见
- WPF中PreviewMouseDownEvent的系统处理:TabItem的PreviewMouseDown 事件弹框后不切换的问题调查
- WPF文字渲染相关的问题及解决
- wpf中的默认右键菜单中的复制、粘贴、剪贴等没有本地化的解决方案
- WPF内部DeliverEvent读锁和PrivateAddListener写锁导致死锁
- Windbg调试WPF的依赖属性
- WPF 后台Render线程崩溃, Exception from HRESULT: 0x88980406
- WPF中DependencyObject与DependencyProperty的源码简单剖析
- 禁用WPF中DataGrid默认的鼠标左键拖动多选行的效果
- wpf工程中在Xaml文件下添加多个cs文件
- ScrollViewer滚动到底来触发加载数据的Behavior