The following Microsoft example code contains the following:
<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>
When run, however, this code generates the following databinding error:
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')
Despite this error, the code works correctly. I have looked through the documentation and DesiredHeight
does not appear to be a member of Border
. Can anyone explain where DesiredHeight
is coming from? Also, is there any way to resolve/suppress this error so my program output is clean?
You can see that property in the code part of your application
Edit:
Border content = new Border();
int desiredHeight = content.DesiredSize.Height;
int desiredWidth = content.DesiredSize.Width;
To solve the problem try binding it to the Height attribute, since DesiredHeight doesn't seem to be available in the XAML markup of the Border control.
Had the same issue. Was using a custom Expander
in a custom ComboBox
.
None of the above worked for me, binding to Height
broke the functionality of the Expander
, using a StackPanel
also broke the displaying of the items in each group. I found:
<Setter TargetName="ContentRow" Property="Height" Value="Auto"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With