WPF Border DesiredHeight WPF Border DesiredHeight wpf wpf

WPF Border DesiredHeight


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"/>


I've ran into this. Along the lines of what user275587 said, their example works because the trigger removes the Heigth="0" on the RowDefination.

So I switch the height setting/trigger logic , so the RowDefination has no Height set

<Grid.RowDefinitions>     <RowDefinition Height="Auto"/>     <RowDefinition Name="ContentRow" /></Grid.RowDefinitions>...<ControlTemplate.Triggers>     <Trigger Property="IsExpanded" Value="False">             <Setter TargetName="ContentRow" Property="Height" Value="0" />     </Trigger></ControlTemplate.Triggers>