Finished wino expander implementation.
This commit is contained in:
@@ -192,10 +192,12 @@ namespace Wino.Core.MenuItems
|
|||||||
item.IsExpanded = false;
|
item.IsExpanded = false;
|
||||||
item.IsSelected = false;
|
item.IsSelected = false;
|
||||||
|
|
||||||
Remove(item);
|
try
|
||||||
|
{
|
||||||
|
Remove(item);
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
});
|
});
|
||||||
|
|
||||||
// RemoveRange(itemsToRemove);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace Wino.Controls.Advanced
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static readonly DependencyProperty LoadMoreCommandProperty = DependencyProperty.Register(nameof(LoadMoreCommand), typeof(ICommand), typeof(WinoListView), new PropertyMetadata(null));
|
public static readonly DependencyProperty LoadMoreCommandProperty = DependencyProperty.Register(nameof(LoadMoreCommand), typeof(ICommand), typeof(WinoListView), new PropertyMetadata(null));
|
||||||
public static readonly DependencyProperty IsThreadListViewProperty = DependencyProperty.Register(nameof(IsThreadListView), typeof(bool), typeof(WinoListView), new PropertyMetadata(false));
|
public static readonly DependencyProperty IsThreadListViewProperty = DependencyProperty.Register(nameof(IsThreadListView), typeof(bool), typeof(WinoListView), new PropertyMetadata(false, new PropertyChangedCallback(OnIsThreadViewChanged)));
|
||||||
public static readonly DependencyProperty ItemDeletedCommandProperty = DependencyProperty.Register(nameof(ItemDeletedCommand), typeof(ICommand), typeof(WinoListView), new PropertyMetadata(null));
|
public static readonly DependencyProperty ItemDeletedCommandProperty = DependencyProperty.Register(nameof(ItemDeletedCommand), typeof(ICommand), typeof(WinoListView), new PropertyMetadata(null));
|
||||||
|
|
||||||
public WinoListView()
|
public WinoListView()
|
||||||
@@ -64,7 +64,6 @@ namespace Wino.Controls.Advanced
|
|||||||
DragItemsCompleted += ItemDragCompleted;
|
DragItemsCompleted += ItemDragCompleted;
|
||||||
DragItemsStarting += ItemDragStarting;
|
DragItemsStarting += ItemDragStarting;
|
||||||
SelectionChanged += SelectedItemsChanged;
|
SelectionChanged += SelectedItemsChanged;
|
||||||
ItemClick += MailItemClicked;
|
|
||||||
ProcessKeyboardAccelerators += ProcessDelKey;
|
ProcessKeyboardAccelerators += ProcessDelKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,6 +83,22 @@ namespace Wino.Controls.Advanced
|
|||||||
internalScrollviewer.ViewChanged += InternalScrollVeiwerViewChanged;
|
internalScrollviewer.ViewChanged += InternalScrollVeiwerViewChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void OnIsThreadViewChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
|
||||||
|
{
|
||||||
|
if (obj is WinoListView winoListView)
|
||||||
|
{
|
||||||
|
winoListView.AdjustThreadViewContainerVisuals();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AdjustThreadViewContainerVisuals()
|
||||||
|
{
|
||||||
|
if (IsThreadListView)
|
||||||
|
{
|
||||||
|
ItemContainerTransitions.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private double lastestRaisedOffset = 0;
|
private double lastestRaisedOffset = 0;
|
||||||
private int lastItemSize = 0;
|
private int lastItemSize = 0;
|
||||||
|
|
||||||
@@ -159,19 +174,6 @@ namespace Wino.Controls.Advanced
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MailItemClicked(object sender, ItemClickEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.ClickedItem is ThreadMailItemViewModel clickedThread)
|
|
||||||
{
|
|
||||||
clickedThread.IsThreadExpanded = !clickedThread.IsThreadExpanded;
|
|
||||||
|
|
||||||
if (!clickedThread.IsThreadExpanded)
|
|
||||||
{
|
|
||||||
SelectedItems.Clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ChangeSelectionMode(ListViewSelectionMode selectionMode)
|
public void ChangeSelectionMode(ListViewSelectionMode selectionMode)
|
||||||
{
|
{
|
||||||
SelectionMode = selectionMode;
|
SelectionMode = selectionMode;
|
||||||
@@ -293,6 +295,10 @@ namespace Wino.Controls.Advanced
|
|||||||
removedMailItemViewModel.IsSelected = false;
|
removedMailItemViewModel.IsSelected = false;
|
||||||
WeakReferenceMessenger.Default.Send(new MailItemSelectionRemovedEvent(removedMailItemViewModel));
|
WeakReferenceMessenger.Default.Send(new MailItemSelectionRemovedEvent(removedMailItemViewModel));
|
||||||
}
|
}
|
||||||
|
else if (removedItem is ThreadMailItemViewModel removedThreadItemViewModel)
|
||||||
|
{
|
||||||
|
removedThreadItemViewModel.IsThreadExpanded = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,7 +319,7 @@ namespace Wino.Controls.Advanced
|
|||||||
// threadMailItemViewModel.IsThreadExpanded = true;
|
// threadMailItemViewModel.IsThreadExpanded = true;
|
||||||
|
|
||||||
// Don't select thread containers.
|
// Don't select thread containers.
|
||||||
SelectedItems.Remove(addedItem);
|
// SelectedItems.Remove(addedItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -341,10 +347,10 @@ namespace Wino.Controls.Advanced
|
|||||||
{
|
{
|
||||||
// Tell main list view to unselect all his items.
|
// Tell main list view to unselect all his items.
|
||||||
|
|
||||||
if (SelectedItems[0] is MailItemViewModel selectedMailItemViewModel)
|
//if (SelectedItems[0] is MailItemViewModel selectedMailItemViewModel)
|
||||||
{
|
//{
|
||||||
WeakReferenceMessenger.Default.Send(new ResetSingleMailItemSelectionEvent(selectedMailItemViewModel));
|
// WeakReferenceMessenger.Default.Send(new ResetSingleMailItemSelectionEvent(selectedMailItemViewModel));
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -369,7 +375,6 @@ namespace Wino.Controls.Advanced
|
|||||||
DragItemsCompleted -= ItemDragCompleted;
|
DragItemsCompleted -= ItemDragCompleted;
|
||||||
DragItemsStarting -= ItemDragStarting;
|
DragItemsStarting -= ItemDragStarting;
|
||||||
SelectionChanged -= SelectedItemsChanged;
|
SelectionChanged -= SelectedItemsChanged;
|
||||||
ItemClick -= MailItemClicked;
|
|
||||||
ProcessKeyboardAccelerators -= ProcessDelKey;
|
ProcessKeyboardAccelerators -= ProcessDelKey;
|
||||||
|
|
||||||
if (internalScrollviewer != null)
|
if (internalScrollviewer != null)
|
||||||
|
|||||||
@@ -80,8 +80,6 @@ namespace Wino.Controls
|
|||||||
control.UpdateInformation();
|
control.UpdateInformation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private async void UpdateInformation()
|
private async void UpdateInformation()
|
||||||
{
|
{
|
||||||
if (KnownHostImage == null || InitialsGrid == null || InitialsTextblock == null || (string.IsNullOrEmpty(FromName) && string.IsNullOrEmpty(FromAddress)))
|
if (KnownHostImage == null || InitialsGrid == null || InitialsTextblock == null || (string.IsNullOrEmpty(FromName) && string.IsNullOrEmpty(FromAddress)))
|
||||||
|
|||||||
@@ -2,10 +2,12 @@
|
|||||||
x:Class="Wino.Controls.MailItemDisplayInformationControl"
|
x:Class="Wino.Controls.MailItemDisplayInformationControl"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:animatedvisuals="using:Microsoft.UI.Xaml.Controls.AnimatedVisuals"
|
||||||
xmlns:controls="using:Wino.Controls"
|
xmlns:controls="using:Wino.Controls"
|
||||||
xmlns:domain="using:Wino.Core.Domain"
|
xmlns:domain="using:Wino.Core.Domain"
|
||||||
xmlns:enums="using:Wino.Core.Domain.Enums"
|
xmlns:enums="using:Wino.Core.Domain.Enums"
|
||||||
xmlns:helpers="using:Wino.Helpers"
|
xmlns:helpers="using:Wino.Helpers"
|
||||||
|
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
HorizontalContentAlignment="Stretch"
|
HorizontalContentAlignment="Stretch"
|
||||||
@@ -154,13 +156,29 @@
|
|||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<FontIcon
|
<local:AnimatedIcon
|
||||||
x:Name="ExpanderChevron"
|
xmlns:local="using:Microsoft.UI.Xaml.Controls"
|
||||||
Margin="0,0,2,0"
|
x:Name="ExpandCollapseChevron"
|
||||||
FontFamily="{ThemeResource SymbolThemeFontFamily}"
|
Width="14"
|
||||||
FontSize="12"
|
Height="14"
|
||||||
Glyph=""
|
Margin="-4,0,2,0"
|
||||||
Visibility="{x:Bind IsThreadExpanderVisible, Mode=OneWay}" />
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
local:AnimatedIcon.State="NormalOff"
|
||||||
|
AutomationProperties.AccessibilityView="Raw"
|
||||||
|
Foreground="{ThemeResource ApplicationForegroundThemeBrush}"
|
||||||
|
RenderTransformOrigin="0.5, 0.5"
|
||||||
|
Visibility="{x:Bind IsThreadExpanderVisible, Mode=OneWay}">
|
||||||
|
<animatedvisuals:AnimatedChevronRightDownSmallVisualSource />
|
||||||
|
<local:AnimatedIcon.FallbackIconSource>
|
||||||
|
<local:FontIconSource
|
||||||
|
FontFamily="{StaticResource SymbolThemeFontFamily}"
|
||||||
|
FontSize="12"
|
||||||
|
Glyph=""
|
||||||
|
IsTextScaleFactorEnabled="False" />
|
||||||
|
</local:AnimatedIcon.FallbackIconSource>
|
||||||
|
<local:AnimatedIcon.RenderTransform />
|
||||||
|
</local:AnimatedIcon>
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
x:Name="TitleText"
|
x:Name="TitleText"
|
||||||
@@ -296,7 +314,7 @@
|
|||||||
<VisualState x:Name="NotExpanded" />
|
<VisualState x:Name="NotExpanded" />
|
||||||
<VisualState x:Name="ExpandedState">
|
<VisualState x:Name="ExpandedState">
|
||||||
<VisualState.Setters>
|
<VisualState.Setters>
|
||||||
<Setter Target="ExpanderChevron.Glyph" Value="" />
|
<Setter Target="ExpandCollapseChevron.(controls:AnimatedIcon.State)" Value="NormalOn" />
|
||||||
</VisualState.Setters>
|
</VisualState.Setters>
|
||||||
<VisualState.StateTriggers>
|
<VisualState.StateTriggers>
|
||||||
<StateTrigger IsActive="{x:Bind IsThreadExpanded, Mode=OneWay}" />
|
<StateTrigger IsActive="{x:Bind IsThreadExpanded, Mode=OneWay}" />
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using Windows.UI.Xaml;
|
using Windows.UI.Xaml;
|
||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
using Windows.UI.Xaml.Input;
|
|
||||||
using Wino.Core.Domain.Entities;
|
using Wino.Core.Domain.Entities;
|
||||||
using Wino.Core.Domain.Enums;
|
using Wino.Core.Domain.Enums;
|
||||||
using Wino.Core.Domain.Models.MailItem;
|
using Wino.Core.Domain.Models.MailItem;
|
||||||
@@ -29,7 +28,7 @@ namespace Wino.Controls
|
|||||||
public static readonly DependencyProperty IsHoverActionsEnabledProperty = DependencyProperty.Register(nameof(IsHoverActionsEnabled), typeof(bool), typeof(MailItemDisplayInformationControl), new PropertyMetadata(true));
|
public static readonly DependencyProperty IsHoverActionsEnabledProperty = DependencyProperty.Register(nameof(IsHoverActionsEnabled), typeof(bool), typeof(MailItemDisplayInformationControl), new PropertyMetadata(true));
|
||||||
public static readonly DependencyProperty Prefer24HourTimeFormatProperty = DependencyProperty.Register(nameof(Prefer24HourTimeFormat), typeof(bool), typeof(MailItemDisplayInformationControl), new PropertyMetadata(false));
|
public static readonly DependencyProperty Prefer24HourTimeFormatProperty = DependencyProperty.Register(nameof(Prefer24HourTimeFormat), typeof(bool), typeof(MailItemDisplayInformationControl), new PropertyMetadata(false));
|
||||||
public static readonly DependencyProperty IsThreadExpanderVisibleProperty = DependencyProperty.Register(nameof(IsThreadExpanderVisible), typeof(bool), typeof(MailItemDisplayInformationControl), new PropertyMetadata(false));
|
public static readonly DependencyProperty IsThreadExpanderVisibleProperty = DependencyProperty.Register(nameof(IsThreadExpanderVisible), typeof(bool), typeof(MailItemDisplayInformationControl), new PropertyMetadata(false));
|
||||||
public static readonly DependencyProperty IsThreadExpandedProperty = DependencyProperty.Register(nameof(IsThreadExpanded), typeof(bool), typeof(MailItemDisplayInformationControl), new PropertyMetadata(false));
|
public static readonly DependencyProperty IsThreadExpandedProperty = DependencyProperty.Register(nameof(IsThreadExpanded), typeof(bool), typeof(MailItemDisplayInformationControl), new PropertyMetadata(false, new PropertyChangedCallback(OnIsExpandedChanged)));
|
||||||
|
|
||||||
public bool IsThreadExpanded
|
public bool IsThreadExpanded
|
||||||
{
|
{
|
||||||
@@ -85,7 +84,6 @@ namespace Wino.Controls
|
|||||||
set { SetValue(RightHoverActionProperty, value); }
|
set { SetValue(RightHoverActionProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public WinoExpander ConnectedExpander
|
public WinoExpander ConnectedExpander
|
||||||
{
|
{
|
||||||
get { return (WinoExpander)GetValue(ConnectedExpanderProperty); }
|
get { return (WinoExpander)GetValue(ConnectedExpanderProperty); }
|
||||||
@@ -122,8 +120,6 @@ namespace Wino.Controls
|
|||||||
set { SetValue(DisplayModeProperty, value); }
|
set { SetValue(DisplayModeProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool tappedHandlingFlag = false;
|
|
||||||
|
|
||||||
public MailItemDisplayInformationControl()
|
public MailItemDisplayInformationControl()
|
||||||
{
|
{
|
||||||
this.InitializeComponent();
|
this.InitializeComponent();
|
||||||
@@ -142,6 +138,20 @@ namespace Wino.Controls
|
|||||||
RootContainerVisualWrapper.SizeChanged += (s, e) => leftBackgroundVisual.Size = e.NewSize.ToVector2();
|
RootContainerVisualWrapper.SizeChanged += (s, e) => leftBackgroundVisual.Size = e.NewSize.ToVector2();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void OnIsExpandedChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
|
||||||
|
{
|
||||||
|
if (obj is MailItemDisplayInformationControl control)
|
||||||
|
{
|
||||||
|
control.AdjustRotation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AdjustRotation()
|
||||||
|
{
|
||||||
|
|
||||||
|
// ExpanderChevronGrid.Rotation = IsThreadExpanded ? 45 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
private void ControlPointerEntered(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
|
private void ControlPointerEntered(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (IsHoverActionsEnabled)
|
if (IsHoverActionsEnabled)
|
||||||
@@ -169,29 +179,9 @@ namespace Wino.Controls
|
|||||||
|
|
||||||
if (package == null) return;
|
if (package == null) return;
|
||||||
|
|
||||||
tappedHandlingFlag = true;
|
|
||||||
|
|
||||||
HoverActionExecutedCommand?.Execute(package);
|
HoverActionExecutedCommand?.Execute(package);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ThreadHeaderTapped(object sender, TappedRoutedEventArgs e)
|
|
||||||
{
|
|
||||||
// Due to CanDrag=True, outer expander doesn't get the click event and it doesn't expand. We expand here manually.
|
|
||||||
// Also hover action button clicks will be delegated here after the execution runs.
|
|
||||||
// We should not expand the thread if the reason we are here is for hover actions.
|
|
||||||
|
|
||||||
//if (tappedHandlingFlag)
|
|
||||||
//{
|
|
||||||
// tappedHandlingFlag = false;
|
|
||||||
// e.Handled = true;
|
|
||||||
// return;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//if (ConnectedExpander == null) return;
|
|
||||||
|
|
||||||
//ConnectedExpander.IsExpanded = !ConnectedExpander.IsExpanded;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FirstActionClicked(object sender, RoutedEventArgs e)
|
private void FirstActionClicked(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
ExecuteHoverAction(LeftHoverAction);
|
ExecuteHoverAction(LeftHoverAction);
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using Windows.UI.Xaml;
|
using CommunityToolkit.Diagnostics;
|
||||||
|
using Windows.UI.Xaml;
|
||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
|
using Windows.UI.Xaml.Hosting;
|
||||||
using Windows.UI.Xaml.Markup;
|
using Windows.UI.Xaml.Markup;
|
||||||
|
|
||||||
namespace Wino.Controls
|
namespace Wino.Controls
|
||||||
@@ -7,15 +9,18 @@ namespace Wino.Controls
|
|||||||
[ContentProperty(Name = nameof(Content))]
|
[ContentProperty(Name = nameof(Content))]
|
||||||
public class WinoExpander : Control
|
public class WinoExpander : Control
|
||||||
{
|
{
|
||||||
|
private const string PART_HeaderGrid = "HeaderGrid";
|
||||||
|
private const string PART_ContentAreaWrapper = "ContentAreaWrapper";
|
||||||
|
private const string PART_ContentArea = "ContentArea";
|
||||||
|
|
||||||
|
private ContentControl HeaderGrid;
|
||||||
|
private ContentControl ContentArea;
|
||||||
|
private Grid ContentAreaWrapper;
|
||||||
|
|
||||||
public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register(nameof(Header), typeof(UIElement), typeof(WinoExpander), new PropertyMetadata(null));
|
public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register(nameof(Header), typeof(UIElement), typeof(WinoExpander), new PropertyMetadata(null));
|
||||||
public static readonly DependencyProperty ContentProperty = DependencyProperty.Register(nameof(Content), typeof(UIElement), typeof(WinoExpander), new PropertyMetadata(null));
|
public static readonly DependencyProperty ContentProperty = DependencyProperty.Register(nameof(Content), typeof(UIElement), typeof(WinoExpander), new PropertyMetadata(null));
|
||||||
public static readonly DependencyProperty IsExpandedProperty = DependencyProperty.Register(nameof(IsExpanded), typeof(bool), typeof(WinoExpander), new PropertyMetadata(false, new PropertyChangedCallback(OnIsExpandedChanged)));
|
public static readonly DependencyProperty IsExpandedProperty = DependencyProperty.Register(nameof(IsExpanded), typeof(bool), typeof(WinoExpander), new PropertyMetadata(false, new PropertyChangedCallback(OnIsExpandedChanged)));
|
||||||
|
public static readonly DependencyProperty TemplateSettingsProperty = DependencyProperty.Register(nameof(TemplateSettings), typeof(WinoExpanderTemplateSettings), typeof(WinoExpander), new PropertyMetadata(new WinoExpanderTemplateSettings()));
|
||||||
public bool IsExpanded
|
|
||||||
{
|
|
||||||
get { return (bool)GetValue(IsExpandedProperty); }
|
|
||||||
set { SetValue(IsExpandedProperty, value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public UIElement Content
|
public UIElement Content
|
||||||
{
|
{
|
||||||
@@ -23,12 +28,54 @@ namespace Wino.Controls
|
|||||||
set { SetValue(ContentProperty, value); }
|
set { SetValue(ContentProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WinoExpanderTemplateSettings TemplateSettings
|
||||||
|
{
|
||||||
|
get { return (WinoExpanderTemplateSettings)GetValue(TemplateSettingsProperty); }
|
||||||
|
set { SetValue(TemplateSettingsProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsExpanded
|
||||||
|
{
|
||||||
|
get { return (bool)GetValue(IsExpandedProperty); }
|
||||||
|
set { SetValue(IsExpandedProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
public UIElement Header
|
public UIElement Header
|
||||||
{
|
{
|
||||||
get { return (UIElement)GetValue(HeaderProperty); }
|
get { return (UIElement)GetValue(HeaderProperty); }
|
||||||
set { SetValue(HeaderProperty, value); }
|
set { SetValue(HeaderProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnApplyTemplate()
|
||||||
|
{
|
||||||
|
base.OnApplyTemplate();
|
||||||
|
|
||||||
|
HeaderGrid = GetTemplateChild(PART_HeaderGrid) as ContentControl;
|
||||||
|
ContentAreaWrapper = GetTemplateChild(PART_ContentAreaWrapper) as Grid;
|
||||||
|
ContentArea = GetTemplateChild(PART_ContentArea) as ContentControl;
|
||||||
|
|
||||||
|
Guard.IsNotNull(HeaderGrid, nameof(HeaderGrid));
|
||||||
|
Guard.IsNotNull(ContentAreaWrapper, nameof(ContentAreaWrapper));
|
||||||
|
Guard.IsNotNull(ContentArea, nameof(ContentArea));
|
||||||
|
|
||||||
|
var clipComposition = ElementCompositionPreview.GetElementVisual(ContentAreaWrapper);
|
||||||
|
clipComposition.Clip = clipComposition.Compositor.CreateInsetClip();
|
||||||
|
|
||||||
|
ContentAreaWrapper.SizeChanged += ContentSizeChanged;
|
||||||
|
HeaderGrid.Tapped += HeaderTapped;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ContentSizeChanged(object sender, SizeChangedEventArgs e)
|
||||||
|
{
|
||||||
|
TemplateSettings.ContentHeight = e.NewSize.Height;
|
||||||
|
TemplateSettings.NegativeContentHeight = -1 * (double)e.NewSize.Height;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HeaderTapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
|
||||||
|
{
|
||||||
|
IsExpanded = !IsExpanded;
|
||||||
|
}
|
||||||
|
|
||||||
private static void OnIsExpandedChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
|
private static void OnIsExpandedChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
|
||||||
{
|
{
|
||||||
if (obj is WinoExpander control)
|
if (obj is WinoExpander control)
|
||||||
@@ -40,4 +87,33 @@ namespace Wino.Controls
|
|||||||
VisualStateManager.GoToState(this, IsExpanded ? "Expanded" : "Collapsed", true);
|
VisualStateManager.GoToState(this, IsExpanded ? "Expanded" : "Collapsed", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Settings
|
||||||
|
|
||||||
|
public class WinoExpanderTemplateSettings : DependencyObject
|
||||||
|
{
|
||||||
|
public static readonly DependencyProperty HeaderHeightProperty = DependencyProperty.Register(nameof(HeaderHeight), typeof(double), typeof(WinoExpanderTemplateSettings), new PropertyMetadata(0.0));
|
||||||
|
public static readonly DependencyProperty ContentHeightProperty = DependencyProperty.Register(nameof(ContentHeight), typeof(double), typeof(WinoExpanderTemplateSettings), new PropertyMetadata(0.0));
|
||||||
|
public static readonly DependencyProperty NegativeContentHeightProperty = DependencyProperty.Register(nameof(NegativeContentHeight), typeof(double), typeof(WinoExpanderTemplateSettings), new PropertyMetadata(0.0));
|
||||||
|
|
||||||
|
public double NegativeContentHeight
|
||||||
|
{
|
||||||
|
get { return (double)GetValue(NegativeContentHeightProperty); }
|
||||||
|
set { SetValue(NegativeContentHeightProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public double HeaderHeight
|
||||||
|
{
|
||||||
|
get { return (double)GetValue(HeaderHeightProperty); }
|
||||||
|
set { SetValue(HeaderHeightProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public double ContentHeight
|
||||||
|
{
|
||||||
|
get { return (double)GetValue(ContentHeightProperty); }
|
||||||
|
set { SetValue(ContentHeightProperty, value); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,65 +13,68 @@
|
|||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<!-- Header -->
|
<!-- Header -->
|
||||||
<Grid Background="{TemplateBinding Background}">
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="Auto" />
|
|
||||||
<ColumnDefinition Width="*" />
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
|
|
||||||
<muxc:AnimatedIcon
|
|
||||||
xmlns:local="using:Microsoft.UI.Xaml.Controls"
|
|
||||||
x:Name="ExpandCollapseChevron"
|
|
||||||
Width="{StaticResource ExpanderChevronGlyphSize}"
|
|
||||||
Height="{StaticResource ExpanderChevronGlyphSize}"
|
|
||||||
HorizontalAlignment="Center"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
local:AnimatedIcon.State="NormalOff"
|
|
||||||
AutomationProperties.AccessibilityView="Raw"
|
|
||||||
Foreground="{ThemeResource ExpanderChevronForeground}"
|
|
||||||
RenderTransformOrigin="0.5, 0.5"
|
|
||||||
Visibility="Collapsed">
|
|
||||||
<animatedvisuals:AnimatedChevronRightDownSmallVisualSource />
|
|
||||||
<muxc:AnimatedIcon.FallbackIconSource>
|
|
||||||
<muxc:FontIconSource
|
|
||||||
FontFamily="{StaticResource SymbolThemeFontFamily}"
|
|
||||||
FontSize="12"
|
|
||||||
Glyph="{StaticResource ExpanderChevronDownGlyph}"
|
|
||||||
IsTextScaleFactorEnabled="False" />
|
|
||||||
</muxc:AnimatedIcon.FallbackIconSource>
|
|
||||||
<muxc:AnimatedIcon.RenderTransform />
|
|
||||||
</muxc:AnimatedIcon>
|
|
||||||
|
|
||||||
|
|
||||||
<ContentControl
|
|
||||||
x:Name="HeaderGrid"
|
|
||||||
Grid.Column="1"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Stretch"
|
|
||||||
HorizontalContentAlignment="Stretch"
|
|
||||||
VerticalContentAlignment="Stretch"
|
|
||||||
Content="{TemplateBinding Header}" />
|
|
||||||
</Grid>
|
|
||||||
|
|
||||||
<ContentControl
|
<ContentControl
|
||||||
x:Name="ContentArea"
|
x:Name="HeaderGrid"
|
||||||
Grid.Row="1"
|
Grid.Column="1"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
HorizontalContentAlignment="Stretch"
|
HorizontalContentAlignment="Stretch"
|
||||||
VerticalContentAlignment="Stretch"
|
VerticalContentAlignment="Stretch"
|
||||||
Content="{TemplateBinding Content}"
|
Background="{TemplateBinding Background}"
|
||||||
Visibility="Collapsed" />
|
Content="{TemplateBinding Header}" />
|
||||||
|
|
||||||
|
<!-- Content -->
|
||||||
|
<Grid x:Name="ContentAreaWrapper" Grid.Row="1">
|
||||||
|
<ContentControl
|
||||||
|
x:Name="ContentArea"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
HorizontalContentAlignment="Stretch"
|
||||||
|
VerticalContentAlignment="Stretch"
|
||||||
|
Content="{TemplateBinding Content}"
|
||||||
|
RenderTransformOrigin="0.5,0.5"
|
||||||
|
Visibility="Collapsed">
|
||||||
|
<ContentControl.RenderTransform>
|
||||||
|
<CompositeTransform />
|
||||||
|
</ContentControl.RenderTransform>
|
||||||
|
</ContentControl>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
<VisualStateManager.VisualStateGroups>
|
<VisualStateManager.VisualStateGroups>
|
||||||
<VisualStateGroup x:Name="OpenCloseStates">
|
<VisualStateGroup x:Name="OpenCloseStates">
|
||||||
<VisualState x:Name="Collapsed" />
|
<VisualState x:Name="Collapsed">
|
||||||
|
<VisualState.Storyboard>
|
||||||
|
<Storyboard>
|
||||||
|
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentArea" Storyboard.TargetProperty="Visibility">
|
||||||
|
<DiscreteObjectKeyFrame KeyTime="0:0:0.111" Value="Collapsed" />
|
||||||
|
</ObjectAnimationUsingKeyFrames>
|
||||||
|
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentArea" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)">
|
||||||
|
<DiscreteDoubleKeyFrame KeyTime="0" Value="0" />
|
||||||
|
<SplineDoubleKeyFrame
|
||||||
|
KeySpline="1.0, 1.0, 0.0, 1.0"
|
||||||
|
KeyTime="0:0:0.111"
|
||||||
|
Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.NegativeContentHeight}" />
|
||||||
|
</DoubleAnimationUsingKeyFrames>
|
||||||
|
</Storyboard>
|
||||||
|
</VisualState.Storyboard>
|
||||||
|
</VisualState>
|
||||||
<VisualState x:Name="Expanded">
|
<VisualState x:Name="Expanded">
|
||||||
<VisualState.Setters>
|
<VisualState.Storyboard>
|
||||||
<Setter Target="ExpandCollapseChevron.(controls:AnimatedIcon.State)" Value="NormalOn" />
|
<Storyboard>
|
||||||
<Setter Target="ContentArea.Visibility" Value="Visible" />
|
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentArea" Storyboard.TargetProperty="Visibility">
|
||||||
</VisualState.Setters>
|
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible" />
|
||||||
|
</ObjectAnimationUsingKeyFrames>
|
||||||
|
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentArea" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)">
|
||||||
|
<DiscreteDoubleKeyFrame KeyTime="0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.NegativeContentHeight}" />
|
||||||
|
<SplineDoubleKeyFrame
|
||||||
|
KeySpline="0.0, 0.0, 0.0, 1.0"
|
||||||
|
KeyTime="0:0:0.333"
|
||||||
|
Value="0" />
|
||||||
|
</DoubleAnimationUsingKeyFrames>
|
||||||
|
</Storyboard>
|
||||||
|
</VisualState.Storyboard>
|
||||||
</VisualState>
|
</VisualState>
|
||||||
</VisualStateGroup>
|
</VisualStateGroup>
|
||||||
</VisualStateManager.VisualStateGroups>
|
</VisualStateManager.VisualStateGroups>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace Wino.Styles
|
|||||||
{
|
{
|
||||||
public WinoExpanderStyle()
|
public WinoExpanderStyle()
|
||||||
{
|
{
|
||||||
this.InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -536,8 +536,8 @@
|
|||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Include="Styles\WinoExpanderStyle.xaml">
|
<Page Include="Styles\WinoExpanderStyle.xaml">
|
||||||
<SubType>Designer</SubType>
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Include="Styles\WinoInfoBar.xaml">
|
<Page Include="Styles\WinoInfoBar.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
|
|||||||
Reference in New Issue
Block a user