??
我們用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