Skip to content

Commit eda35bd

Browse files
authored
[STYLE] Expander animations (#305)
* Expander animations * fix corner radius regression * expander page example with options * fixed animation * settings expander corner radii * chore: clean unnecessary changes
1 parent 70f0123 commit eda35bd

File tree

5 files changed

+108
-231
lines changed

5 files changed

+108
-231
lines changed

source/iNKORE.UI.WPF.Modern.Controls/Controls/Community/SettingsControls/SettingsExpander/SettingsExpander.xaml

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:chelper="clr-namespace:iNKORE.UI.WPF.Modern.Controls.Helpers;assembly=iNKORE.UI.WPF.Modern"
55
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
6+
xmlns:converters="clr-namespace:iNKORE.UI.WPF.Modern.Common.Converters;assembly=iNKORE.UI.WPF.Modern"
7+
xmlns:common="clr-namespace:iNKORE.UI.WPF.Modern.Common;assembly=iNKORE.UI.WPF.Modern"
68
xmlns:local="clr-namespace:iNKORE.UI.WPF.Modern.Controls"
79
xmlns:sys="clr-namespace:System;assembly=System.Runtime"
810
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern">
@@ -146,10 +148,6 @@
146148
<ikw:CornerRadiusFilterConverter x:Key="LeftCornerRadiusFilterConverter" Filter="Left" />
147149

148150
<ikw:SizeToRectConverter x:Key="SizeToRectConverter" />
149-
150-
<sys:TimeSpan x:Key="ExpandAnimationDuration">0:0:0.333</sys:TimeSpan>
151-
<sys:TimeSpan x:Key="CollapseAnimationDuration">0:0:0.167</sys:TimeSpan>
152-
153151
<Style x:Key="SettingsExpanderExpanderStyle" TargetType="Expander">
154152
<Setter Property="Background" Value="{DynamicResource ExpanderContentBackground}" />
155153
<Setter Property="MinWidth" Value="{DynamicResource FlyoutThemeMinWidth}" />
@@ -160,10 +158,9 @@
160158
<Setter Property="HorizontalAlignment" Value="Left" />
161159
<Setter Property="VerticalAlignment" Value="Center" />
162160
<Setter Property="ui:ControlHelper.CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
163-
<Setter Property="chelper:ExpanderAnimationsHelper.CollapseAnimationDuration" Value="{DynamicResource CollapseAnimationDuration}" />
164-
<Setter Property="chelper:ExpanderAnimationsHelper.ExpandAnimationDuration" Value="{DynamicResource ExpandAnimationDuration}" />
165-
<Setter Property="chelper:ExpanderAnimationsHelper.ToAnimateControlName" Value="ExpanderContent" />
166161
<Setter Property="chelper:ExpanderAnimationsHelper.IsEnabled" Value="True" />
162+
<Setter Property="chelper:ExpanderAnimationsHelper.ExpandAnimationDuration" Value="{DynamicResource ExpandAnimationDuration}" />
163+
<Setter Property="chelper:ExpanderAnimationsHelper.CollapseAnimationDuration" Value="{DynamicResource CollapseAnimationDuration}" />
167164
<Setter Property="Template">
168165
<Setter.Value>
169166
<ControlTemplate TargetType="Expander">
@@ -174,27 +171,8 @@
174171
</Grid.RowDefinitions>
175172

176173
<!-- The clip is a composition clip applied in code -->
177-
<Border x:Name="ExpanderContentClip" Grid.Row="1">
178-
179-
<Border.Clip>
180-
<RectangleGeometry>
181-
<RectangleGeometry.Rect>
182-
<MultiBinding Converter="{StaticResource SizeToRectConverter}">
183-
<Binding Source="0" />
184-
<Binding Source="0" />
185-
<Binding
186-
Mode="OneWay"
187-
Path="ActualWidth"
188-
RelativeSource="{RelativeSource Mode=TemplatedParent}" />
189-
<Binding
190-
ElementName="ContentPresenter"
191-
Mode="OneWay"
192-
Path="ActualHeight" />
193-
</MultiBinding>
194-
</RectangleGeometry.Rect>
195-
</RectangleGeometry>
196-
</Border.Clip>
197-
174+
<ikw:ClippedContent x:Name="ExpanderContentClip" Grid.Row="1"
175+
ClipToBounds="True">
198176
<ikw:ClippedContent
199177
x:Name="ExpanderContent"
200178
MinHeight="{DynamicResource SettingsExpanderContentMinHeight}"
@@ -204,11 +182,11 @@
204182
BorderBrush="{TemplateBinding BorderBrush}"
205183
BorderThickness="{StaticResource ExpanderContentDownBorderThickness}"
206184
CornerRadius="{TemplateBinding ui:ControlHelper.CornerRadius,
207-
Converter={StaticResource BottomCornerRadiusFilterConverter}}"
208-
Visibility="Collapsed">
185+
Converter={StaticResource BottomCornerRadiusFilterConverter}}">
209186
<FrameworkElement.RenderTransform>
210187
<TranslateTransform x:Name="ExpanderContentTranslation" />
211188
</FrameworkElement.RenderTransform>
189+
212190
<ui:ContentPresenterEx
213191
x:Name="ContentPresenter"
214192
Margin="0,-2,0,0"
@@ -218,7 +196,7 @@
218196
ContentTemplate="{TemplateBinding ContentTemplate}"
219197
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" />
220198
</ikw:ClippedContent>
221-
</Border>
199+
</ikw:ClippedContent>
222200

223201
<ToggleButton x:Name="ExpanderHeader"
224202
MinHeight="{TemplateBinding MinHeight}"
@@ -238,10 +216,11 @@
238216
IsEnabled="{TemplateBinding IsEnabled}"
239217
IsTabStop="True"
240218
Style="{StaticResource SettingsExpanderHeaderDownStyle}"
241-
Tag="{TemplateBinding chelper:ControlHelper.CornerRadius}" />
219+
Tag="{TemplateBinding chelper:ControlHelper.CornerRadius}"/>
242220
</Grid>
221+
243222
<ControlTemplate.Triggers>
244-
<MultiTrigger>
223+
<MultiTrigger>
245224
<MultiTrigger.Conditions>
246225
<Condition Property="IsExpanded" Value="true" />
247226
<Condition Property="ExpandDirection" Value="Down" />
@@ -277,6 +256,7 @@
277256
<Setter TargetName="ExpanderHeader" Property="chelper:ControlHelper.CornerRadius" Value="{Binding Tag, ElementName=ExpanderHeader, Converter={StaticResource RightCornerRadiusFilterConverter}}" />
278257
</MultiTrigger.Setters>
279258
</MultiTrigger>
259+
280260
</ControlTemplate.Triggers>
281261
</ControlTemplate>
282262
</Setter.Value>

source/iNKORE.UI.WPF.Modern.Gallery/Pages/Controls/Windows/ExpanderPage.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,4 @@ public void UpdateExampleCode()
171171
#endregion
172172

173173
}
174-
}
174+
}

0 commit comments

Comments
 (0)