Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(GH-3812) Fix wrong space for Expander before expanded #3816

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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