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

feat(Expander): add ability to change expander orientation #1336

Merged
merged 7 commits into from
Aug 21, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -25,7 +25,7 @@
Orientation="{Binding Orientation.Value, Mode=TwoWay}"
TooltipPlacement="{Binding TooltipPlacement.Value, Mode=TwoWay}">

<controls:MenuItem Name="FileMenu"
<controls:MenuItem x:Name="FileMenu"
controls:Menu.InputGestureText="Alt+F">
<controls:MenuItem.Header>
<StackPanel Orientation="Horizontal">
Expand Down
9 changes: 3 additions & 6 deletions Microsoft.Toolkit.Uwp.UI.Controls/Expander/Expander.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Markup;
using WinRTXamlToolkit.Controls;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to move it to a better namespace.


namespace Microsoft.Toolkit.Uwp.UI.Controls
{
Expand All @@ -30,7 +31,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
[TemplateVisualState(Name = StateContentUpDirection, GroupName = ExpandDirectionGroupStateContent)]
[TemplatePart(Name = RootGridPart, Type = typeof(Grid))]
[TemplatePart(Name = ExpanderToggleButtonPart, Type = typeof(ToggleButton))]
[TemplatePart(Name = LayoutTransformerPart, Type = typeof(LayoutTransformer))]
[TemplatePart(Name = LayoutTransformerPart, Type = typeof(LayoutTransformControl))]
[ContentProperty(Name = "Content")]
public partial class Expander : ContentControl
{
Expand Down Expand Up @@ -103,9 +104,8 @@ private void CollapseControl()
public void OnExpandDirectionChanged()
{
var button = (ToggleButton)GetTemplateChild(ExpanderToggleButtonPart);
var layoutTransformer = (LayoutTransformer)GetTemplateChild(LayoutTransformerPart);

if (button == null || layoutTransformer == null)
if (button == null)
{
return;
}
Expand All @@ -130,9 +130,6 @@ public void OnExpandDirectionChanged()
break;
}

// Apply rotation on expander toggle button
layoutTransformer.ApplyLayoutTransform();

// Re-execute animation on expander toggle button (to set correct arrow rotation)
VisualStateManager.GoToState(button, "Normal", true);
if (button.IsChecked.HasValue && button.IsChecked.Value)
Expand Down
13 changes: 7 additions & 6 deletions Microsoft.Toolkit.Uwp.UI.Controls/Expander/Expander.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:winrtcontrols="using:WinRTXamlToolkit.Controls"
mc:Ignorable="d">

<Style x:Key="HeaderToggleButtonStyle" TargetType="ToggleButton">
Expand Down Expand Up @@ -405,12 +406,12 @@
<ColumnDefinition x:Name="ColumnTwo" Width="*" />
</Grid.ColumnDefinitions>

<controls:LayoutTransformer Grid.Row="0" Grid.RowSpan="1" Grid.Column="0" Grid.ColumnSpan="2"
x:Name="PART_LayoutTransformer"
RenderTransformOrigin="0.5,0.5">
<controls:LayoutTransformer.LayoutTransform>
<winrtcontrols:LayoutTransformControl Grid.Row="0" Grid.RowSpan="1" Grid.Column="0" Grid.ColumnSpan="2"
x:Name="PART_LayoutTransformer"
RenderTransformOrigin="0.5,0.5">
<winrtcontrols:LayoutTransformControl.Transform>
<RotateTransform x:Name="RotateLayoutTransform" Angle="0" />
</controls:LayoutTransformer.LayoutTransform>
</winrtcontrols:LayoutTransformControl.Transform>

<ToggleButton x:Name="PART_ExpanderToggleButton"
Height="40"
Expand All @@ -422,7 +423,7 @@
Background="{TemplateBinding Background}"
ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}"
IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" />
</controls:LayoutTransformer>
</winrtcontrols:LayoutTransformControl>

<ContentPresenter Grid.Row="1" Grid.RowSpan="1" Grid.Column="0" Grid.ColumnSpan="2"
x:Name="PART_MainContent"
Expand Down

This file was deleted.

This file was deleted.

Loading