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>
原标题:Debug Databinding Issues in WPF
关键词:wpf
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。