你的位置:首页 > 软件开发 > ASP.net > Debug Databinding Issues in WPF

Debug Databinding Issues in WPF

发布时间:2016-10-12 12:00:25
DataBinding is one of the most powerful features in WPF. But because it resolves the bindings at runtime and does not throw exceptions, its ...

DataBinding is one of the most powerful features in WPF. But because it resolves the bindings at runtime and does not throw exceptions, it's sometimes hard to find the reason why the data do not appear as expected. There are mainly two reasons:

  • The DataBinding expression is invalid. Then use Trace Output to resolve.
  • The DataBinding expression is valid, but the result is not the expected. Then use a Debug Converter to resolve it.

Method 1: Trace messages in the output get='_blank'>window

In the example, the text property of the TextBlock is bound to the property "InvalidPath" of the StackPanel - which does not exists.

<Window x:Class="DebugDataBinding.Window1"  ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  ="http://schemas.microsoft.com/winfx/2006/xaml" >  <StackPanel x:Name="stack">    <TextBlock Text="{Binding ElementName=stack, Path=InvalidPath}" />  </StackPanel></Window>

 

海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com

原标题:Debug Databinding Issues in WPF

关键词:wpf

wpf
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。