Mittwoch, 22. Mai 2013

Tracen bei WPF Bindings

Seit dem .NET Framework 3.5 stellt Microsoft für Debugging Zwecke ein Tracing für WPF zur Verfügung.

 <Button Command="{Binding ReleaseCommand, PresentationTraceSources.TraceLevel=High}">Release</Button>  

Damit hat man die Möglichkeit ein bisschen nach zu vollziehen, was bei den WPF Controls unter der Haube so passiert. Zum Beispiel, wie ein gebundener Wert vor und nach einem Converter ist. Der Trace Level kann  None, Low, Medium oder High sein.
Diese angefügte Eigenschaft kann auf alle Klassen angewendet werden, die von BindingBase oder BindingExpressionBase ableiten. Also für folgende Klassen:
  • Binding
  • MultiBinding
  • PriorityBinding
  • BindingExpression
  • MultiBindingExpression
  • PriorityBindingExpression.
Außerdem ist die auch bei ObjectDataProvider oder XmlDataProvider anwendbar.

Hier nochmal ein Auszug in dem ich ein Command am Button gebunden habe:

 System.Windows.Data Warning: 55 : Created BindingExpression (hash=41717140) for Binding (hash=2418355)  
 System.Windows.Data Warning: 57 :  Path: 'ReleaseCommand'  
 System.Windows.Data Warning: 59 : BindingExpression (hash=41717140): Default mode resolved to OneWay  
 System.Windows.Data Warning: 60 : BindingExpression (hash=41717140): Default update trigger resolved to PropertyChanged  
 System.Windows.Data Warning: 61 : BindingExpression (hash=41717140): Attach to System.Windows.Controls.Button.Command (hash=34101444)  
 System.Windows.Data Warning: 66 : BindingExpression (hash=41717140): Resolving source   
 System.Windows.Data Warning: 69 : BindingExpression (hash=41717140): Found data context element: Button (hash=34101444) (OK)  
 System.Windows.Data Warning: 77 : BindingExpression (hash=41717140): Activate with root item MainViewModel (hash=58169988)  
 System.Windows.Data Warning: 107 : BindingExpression (hash=41717140):  At level 0 - for MainViewModel.ReleaseCommand found accessor RuntimePropertyInfo(ReleaseCommand)  
 System.Windows.Data Warning: 103 : BindingExpression (hash=41717140): Replace item at level 0 with MainViewModel (hash=58169988), using accessor RuntimePropertyInfo(ReleaseCommand)  
 System.Windows.Data Warning: 100 : BindingExpression (hash=41717140): GetValue at level 0 from MainViewModel (hash=58169988) using RuntimePropertyInfo(ReleaseCommand): SimpleCommand`2 (hash=26754911)  
 System.Windows.Data Warning: 79 : BindingExpression (hash=41717140): TransferValue - got raw value SimpleCommand`2 (hash=26754911)  
 System.Windows.Data Warning: 88 : BindingExpression (hash=41717140): TransferValue - using final value SimpleCommand`2 (hash=26754911)  
 System.Windows.Data Warning: 55 : Created BindingExpression (hash=31382336) for Binding (hash=5171309)  
 System.Windows.Data Warning: 57 :  Path: 'ReleaseCommand'  
 System.Windows.Data Warning: 59 : BindingExpression (hash=31382336): Default mode resolved to OneWay  
 System.Windows.Data Warning: 60 : BindingExpression (hash=31382336): Default update trigger resolved to PropertyChanged  
 System.Windows.Data Warning: 61 : BindingExpression (hash=31382336): Attach to WpfControls.HoldButton.Command (hash=2919017)  
 System.Windows.Data Warning: 66 : BindingExpression (hash=31382336): Resolving source   
 System.Windows.Data Warning: 69 : BindingExpression (hash=31382336): Found data context element: HoldButton (hash=2919017) (OK)  
 System.Windows.Data Warning: 77 : BindingExpression (hash=31382336): Activate with root item MainViewModel (hash=58169988)  
 System.Windows.Data Warning: 106 : BindingExpression (hash=31382336):  At level 0 using cached accessor for MainViewModel.ReleaseCommand: RuntimePropertyInfo(ReleaseCommand)  
 System.Windows.Data Warning: 103 : BindingExpression (hash=31382336): Replace item at level 0 with MainViewModel (hash=58169988), using accessor RuntimePropertyInfo(ReleaseCommand)  
 System.Windows.Data Warning: 100 : BindingExpression (hash=31382336): GetValue at level 0 from MainViewModel (hash=58169988) using RuntimePropertyInfo(ReleaseCommand): SimpleCommand`2 (hash=26754911)  
 System.Windows.Data Warning: 79 : BindingExpression (hash=31382336): TransferValue - got raw value SimpleCommand`2 (hash=26754911)  
 System.Windows.Data Warning: 88 : BindingExpression (hash=31382336): TransferValue - using final value SimpleCommand`2 (hash=26754911)  

Keine Kommentare:

Kommentar veröffentlichen