Skip to content
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
37 changes: 37 additions & 0 deletions src/Shared/HandyControl_Shared/Controls/Attach/ExpanderElement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Windows;

namespace HandyControl.Controls;

/// <summary>
/// Header text orientation of an <see cref="Expander"/> when <see cref="Expander.ExpandDirection"/> is Left or Right.
/// </summary>
public enum ExpanderHeaderTextOrientation
{
/// <summary>
/// Same as the current behavior: the whole header is rotated -90 degrees (glyphs lying on their side).
/// </summary>
Default = 0,

/// <summary>
/// Upright vertical: characters stand upright and stack top-to-bottom.
/// </summary>
Vertical = 1,

/// <summary>
/// Upright horizontal: a single horizontal line.
/// </summary>
Horizontal = 2
}

/// <summary>
/// Attached properties for <see cref="Expander"/>.
/// </summary>
public class ExpanderElement
{
public static readonly DependencyProperty HeaderTextOrientationProperty = DependencyProperty.RegisterAttached(
"HeaderTextOrientation", typeof(ExpanderHeaderTextOrientation), typeof(ExpanderElement), new FrameworkPropertyMetadata(ExpanderHeaderTextOrientation.Default));

public static void SetHeaderTextOrientation(DependencyObject element, ExpanderHeaderTextOrientation value) => element.SetValue(HeaderTextOrientationProperty, value);

public static ExpanderHeaderTextOrientation GetHeaderTextOrientation(DependencyObject element) => (ExpanderHeaderTextOrientation) element.GetValue(HeaderTextOrientationProperty);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\DataGridAttach.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\DropDownElement.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\EdgeElement.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\ExpanderElement.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\ComboBoxAttach.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\GridAttach.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\GridViewAttach.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<RotateTransform Angle="-90" />
</TransformGroup>
</Grid.LayoutTransform>
<ContentPresenter ContentSource="Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
<ContentPresenter Name="HeaderText" ContentSource="Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
<Path Name="PathArrow" IsHitTestVisible="False" Grid.Column="1" Stretch="Uniform" Fill="{TemplateBinding Foreground}" Data="{StaticResource UpGeometry}" Width="12" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="Center" />
</Grid>
</ToggleButton>
Expand All @@ -34,6 +34,27 @@
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Opacity" Value=".4" />
</Trigger>
<Trigger Property="hc:ExpanderElement.HeaderTextOrientation" Value="Vertical">
<Setter TargetName="HeaderText" Property="LayoutTransform">
<Setter.Value>
<RotateTransform Angle="90" />
</Setter.Value>
</Setter>
<Setter TargetName="HeaderText" Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{Binding}" TextWrapping="Wrap" TextAlignment="Center" Width="{Binding FontSize, RelativeSource={RelativeSource AncestorType=Expander}}" />
</DataTemplate>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="hc:ExpanderElement.HeaderTextOrientation" Value="Horizontal">
<Setter TargetName="HeaderText" Property="LayoutTransform">
<Setter.Value>
<RotateTransform Angle="90" />
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>

Expand Down Expand Up @@ -84,7 +105,7 @@
<RotateTransform Angle="-90" />
</TransformGroup>
</Grid.LayoutTransform>
<ContentPresenter ContentSource="Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
<ContentPresenter Name="HeaderText" ContentSource="Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
<Path Name="PathArrow" IsHitTestVisible="False" Grid.Column="1" Stretch="Uniform" Fill="{TemplateBinding Foreground}" Data="{StaticResource DownGeometry}" Width="12" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="Center" />
</Grid>
</ToggleButton>
Expand All @@ -99,6 +120,27 @@
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Opacity" Value=".4" />
</Trigger>
<Trigger Property="hc:ExpanderElement.HeaderTextOrientation" Value="Vertical">
<Setter TargetName="HeaderText" Property="LayoutTransform">
<Setter.Value>
<RotateTransform Angle="90" />
</Setter.Value>
</Setter>
<Setter TargetName="HeaderText" Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{Binding}" TextWrapping="Wrap" TextAlignment="Center" Width="{Binding FontSize, RelativeSource={RelativeSource AncestorType=Expander}}" />
</DataTemplate>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="hc:ExpanderElement.HeaderTextOrientation" Value="Horizontal">
<Setter TargetName="HeaderText" Property="LayoutTransform">
<Setter.Value>
<RotateTransform Angle="90" />
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>

Expand Down