Skip to content

Commit

Permalink
Merge pull request #3816 from MahApps/fix/GH-3812-Expander-reserves-i…
Browse files Browse the repository at this point in the history
…nternal-needed-space-before-expanding

(GH-3812) Fix wrong space for Expander before expanded
  • Loading branch information
punker76 authored May 26, 2020
2 parents e313e85 + cda41b2 commit 54071d6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
<TabItem Header="Start">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
Expand Down Expand Up @@ -170,13 +172,18 @@
Header="Hidden Stuff">
<StackPanel Orientation="Vertical">
<TextBlock Text="...42..." />
<Expander ExpandDirection="Down" Header="Second Hidden Stuff">
<Expander ExpandDirection="Down"
Header="Second Hidden Stuff"
IsExpanded="True">
<StackPanel Orientation="Vertical">
<TextBlock Text="...is the Answer to the Ultimate Question of Life, The Universe, and Everything" />
</StackPanel>
</Expander>
</StackPanel>
</Expander>
<Button Grid.Row="2"
Margin="20"
Content="Beam me up..." />
</Grid>
</TabItem>
<TabItem Header="Demo">
Expand Down
4 changes: 3 additions & 1 deletion src/MahApps.Metro/Controls/Helper/ExpanderHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
Expand Down Expand Up @@ -121,6 +121,7 @@ private static void OnExpandStoryboardPropertyChangedCallback(DependencyObject d
}
expandSite.SetCurrentValue(UIElement.OpacityProperty, 1d);
expandSite.SetCurrentValue(UIElement.VisibilityProperty, Visibility.Visible);
}
});

Expand Down Expand Up @@ -214,6 +215,7 @@ private static void OnCollapseStoryboardPropertyChangedCallback(DependencyObject
}
expandSite.SetCurrentValue(UIElement.OpacityProperty, 0d);
expandSite.SetCurrentValue(UIElement.VisibilityProperty, Visibility.Collapsed);
}
});

Expand Down
5 changes: 4 additions & 1 deletion src/MahApps.Metro/Styles/Controls.Expander.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@
To="0"
Duration="0:0:0.25" />
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(UIElement.Visibility)">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}" />
<DiscreteObjectKeyFrame KeyTime="0:0:0.25" Value="{x:Static Visibility.Collapsed}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
Expand Down Expand Up @@ -393,8 +394,10 @@
CornerRadius="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.CornerRadius), Converter={StaticResource CornerRadiusBindingConverter}, ConverterParameter={x:Static Converters:RadiusType.Top}}"
DockPanel.Dock="Bottom"
Focusable="false"
Opacity="0"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
UseLayoutRounding="True">
UseLayoutRounding="True"
Visibility="Collapsed">
<ContentPresenter Margin="{TemplateBinding Padding}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Expand Down
5 changes: 4 additions & 1 deletion src/MahApps.Metro/Styles/VS/Expander.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@
To="0"
Duration="0:0:0.1" />
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(UIElement.Visibility)">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}" />
<DiscreteObjectKeyFrame KeyTime="0:0:0.1" Value="{x:Static Visibility.Collapsed}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
Expand Down Expand Up @@ -375,8 +376,10 @@
BorderThickness="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Converter={StaticResource ThicknessBindingConverter}, ConverterParameter={x:Static Converters:ThicknessSideType.Top}}"
DockPanel.Dock="Bottom"
Focusable="False"
Opacity="0"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
UseLayoutRounding="True">
UseLayoutRounding="True"
Visibility="Collapsed">
<ContentPresenter Margin="{TemplateBinding Padding}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Expand Down

0 comments on commit 54071d6

Please sign in to comment.