以下Microsoft 示例代码包含以下内容:
<Grid>
...
<Border Name="Content" ... >
...
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsExpanded" Value="True">
<Setter TargetName="ContentRow" Property="Height"
Value="{Binding ElementName=Content,Path=DesiredHeight}" />
</Trigger>
...
</ControlTemplate.Triggers>
但是,在运行时,此代码会生成以下数据绑定错误:
System.Windows.Data Error: 39 : BindingExpression path error: 'DesiredHeight' property not found on 'object' ''Border' (Name='Content')'. BindingExpression:Path=DesiredHeight; DataItem='Border' (Name='Content'); target element is 'RowDefinition' (HashCode=2034711); target property is 'Height' (type 'GridLength')
尽管出现此错误,但代码仍可以正常工作。我查看了文档,DesiredHeight
似乎不是Border
. 谁能解释DesiredHeight
来自哪里?另外,有没有办法解决/抑制这个错误,所以我的程序输出是干净的?