Skip to content

Commit

Permalink
Merge pull request #574 from xmine64/expander_animation
Browse files Browse the repository at this point in the history
Expander animation
  • Loading branch information
pomianowski committed Apr 21, 2023
2 parents 1914263 + 7d83ce6 commit 358f726
Show file tree
Hide file tree
Showing 12 changed files with 284 additions and 52 deletions.
8 changes: 8 additions & 0 deletions src/Wpf.Ui.Gallery/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Wpf.Ui.Gallery.ViewModels.Pages.DateAndTime;
using Wpf.Ui.Gallery.ViewModels.Pages.DialogsAndFlyouts;
using Wpf.Ui.Gallery.ViewModels.Pages.Icons;
using Wpf.Ui.Gallery.ViewModels.Pages.Layout;
using Wpf.Ui.Gallery.ViewModels.Pages.Media;
using Wpf.Ui.Gallery.ViewModels.Pages.Navigation;
using Wpf.Ui.Gallery.ViewModels.Pages.StatusAndInfo;
Expand All @@ -25,6 +26,7 @@
using Wpf.Ui.Gallery.Views.Pages.DateAndTime;
using Wpf.Ui.Gallery.Views.Pages.DialogsAndFlyouts;
using Wpf.Ui.Gallery.Views.Pages.Icons;
using Wpf.Ui.Gallery.Views.Pages.Layout;
using Wpf.Ui.Gallery.Views.Pages.Media;
using Wpf.Ui.Gallery.Views.Pages.Navigation;
using Wpf.Ui.Gallery.Views.Pages.Samples;
Expand Down Expand Up @@ -130,6 +132,12 @@ public partial class App : Application
services.AddTransient<MessageBoxPage>();
services.AddTransient<MessageBoxViewModel>();
// Layout
services.AddTransient<LayoutPage>();
services.AddTransient<LayoutViewModel>();
services.AddTransient<ExpanderPage>();
services.AddTransient<ExpanderViewModel>();
// Web View
services.AddTransient<MediaPage>();
services.AddTransient<MediaViewModel>();
Expand Down
9 changes: 9 additions & 0 deletions src/Wpf.Ui.Gallery/ViewModels/Pages/AllControlsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,15 @@ public partial class AllControlsViewModel : ObservableObject
Icon = SymbolRegular.TextFont24,
Description = "Control displaying a single font glyph.",
Link = "FontIcon"
},
#if DEBUG
new()
{
Name = "Expander",
Icon = SymbolRegular.Code24,
Description = "Expander control.",
Link = "Expander"
}
#endif
};
}
13 changes: 13 additions & 0 deletions src/Wpf.Ui.Gallery/ViewModels/Pages/Layout/ExpanderViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.

namespace Wpf.Ui.Gallery.ViewModels.Pages.Layout;

public partial class ExpanderViewModel : ObservableObject
{
public ExpanderViewModel()
{
}
}
27 changes: 27 additions & 0 deletions src/Wpf.Ui.Gallery/ViewModels/Pages/Layout/LayoutViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.

using System.Collections.Generic;
using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
using Wpf.Ui.Common;
using Wpf.Ui.Gallery.Models;

namespace Wpf.Ui.Gallery.ViewModels.Pages.Layout;

public partial class LayoutViewModel : ObservableObject
{
[ObservableProperty]
private ICollection<NavigationCard> _navigationCards = new ObservableCollection<NavigationCard>
{
new()
{
Name = "Expander",
Icon = SymbolRegular.Code24,
Description = "Expander control.",
Link = "Expander"
},
};
}
7 changes: 7 additions & 0 deletions src/Wpf.Ui.Gallery/ViewModels/Windows/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Wpf.Ui.Gallery.Views.Pages.DateAndTime;
using Wpf.Ui.Gallery.Views.Pages.DialogsAndFlyouts;
using Wpf.Ui.Gallery.Views.Pages.Icons;
using Wpf.Ui.Gallery.Views.Pages.Layout;
using Wpf.Ui.Gallery.Views.Pages.Media;
using Wpf.Ui.Gallery.Views.Pages.Navigation;
using Wpf.Ui.Gallery.Views.Pages.StatusAndInfo;
Expand Down Expand Up @@ -80,6 +81,12 @@ public MainWindowViewModel(IServiceProvider serviceProvider)
new NavigationViewItem { Content = "Flyout", TargetPageType = typeof(FlyoutPage) },
new NavigationViewItem { Content = "MessageBox", TargetPageType = typeof(MessageBoxPage) },
}},
#if DEBUG
new NavigationViewItem { Content = "Layout", Icon = new SymbolIcon { Symbol = SymbolRegular.News24}, TargetPageType = typeof(LayoutPage), MenuItems = new ObservableCollection<object>()
{
new NavigationViewItem { Content = "Expander", TargetPageType = typeof(ExpanderPage) },
}},
#endif
new NavigationViewItem {Content = "Media", Icon = new SymbolIcon { Symbol = SymbolRegular.PlayCircle24 }, TargetPageType = typeof(MediaPage), MenuItems = new ObservableCollection<object>
{
new NavigationViewItem { Content = "Image", TargetPageType = typeof(ImagePage) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public ContentDialogPage(ContentDialogViewModel viewModel)
{
ViewModel = viewModel;
DataContext = viewModel;
DataContext = viewModel;

InitializeComponent();
}
Expand Down
61 changes: 61 additions & 0 deletions src/Wpf.Ui.Gallery/Views/Pages/Layout/ExpanderPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<Page
x:Class="Wpf.Ui.Gallery.Views.Pages.Layout.ExpanderPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:basicInput="clr-namespace:Wpf.Ui.Gallery.Views.Pages.BasicInput"
xmlns:controls="clr-namespace:Wpf.Ui.Gallery.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Wpf.Ui.Gallery.Views.Pages.Layout"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:system="clr-namespace:System;assembly=System.Runtime"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
Title="ExpanderPage"
d:DesignHeight="450"
d:DesignWidth="800"
ui:Design.Background="{DynamicResource ApplicationBackgroundBrush}"
ui:Design.Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
mc:Ignorable="d">
<Page.Resources>
<system:String x:Key="PageXamlUrl">https://github.com/lepoco/wpfui/blob/development/src/Wpf.Ui/Styles/Controls/Expander.xaml</system:String>
<system:String x:Key="PageCsharpUrl">https://github.com/lepoco/wpfui/blob/development/src/Wpf.Ui/Controls/Expander.cs</system:String>
</Page.Resources>
<Grid>
<ui:DynamicScrollViewer
x:Name="PageScrollViewer"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="280" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" Margin="42">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<controls:GalleryControlPresenter
Grid.Row="0"
Margin="0"
CodeText="&lt;Expander Header=&quot;This text is in the header&quot; Content=&quot;This is in the content&quot; /&gt;"
HeaderText="An Expander with text in the header and content areas">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Expander
Grid.Column="0"
Content="This is in the content"
Header="This text is in the header" />

<!-- TODO: ExpandDirection -->
</Grid>
</controls:GalleryControlPresenter>
</Grid>
</Grid>
</ui:DynamicScrollViewer>
<controls:ControlDocumentationSummary CsharpUrl="{StaticResource PageCsharpUrl}" XamlUrl="{StaticResource PageXamlUrl}" />
</Grid>
</Page>
19 changes: 19 additions & 0 deletions src/Wpf.Ui.Gallery/Views/Pages/Layout/ExpanderPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Wpf.Ui.Controls.Navigation;
using Wpf.Ui.Gallery.ViewModels.Pages.Layout;

namespace Wpf.Ui.Gallery.Views.Pages.Layout
{
/// <summary>
/// Interaction logic for Expander.xaml
/// </summary>
public partial class ExpanderPage : INavigableView<ExpanderViewModel>
{
public ExpanderPage(ExpanderViewModel viewModel)
{
InitializeComponent();
ViewModel = viewModel;
}

public ExpanderViewModel ViewModel { get; }
}
}
27 changes: 27 additions & 0 deletions src/Wpf.Ui.Gallery/Views/Pages/Layout/LayoutPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Page
x:Class="Wpf.Ui.Gallery.Views.Pages.Layout.LayoutPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:Wpf.Ui.Gallery.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Wpf.Ui.Gallery.Views.Pages.Layout"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:models="clr-namespace:Wpf.Ui.Gallery.Models"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
Title="DialogsAndFlyoutsPage"
d:DataContext="{d:DesignInstance local:LayoutPage,
IsDesignTimeCreatable=False}"
d:DesignHeight="450"
d:DesignWidth="800"
ui:Design.Background="{DynamicResource ApplicationBackgroundBrush}"
ui:Design.Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
mc:Ignorable="d">

<Grid Margin="38">
<controls:GalleryNavigationPresenter
Margin="0"
Padding="0"
ItemsSource="{Binding ViewModel.NavigationCards, Mode=OneWay}" />
</Grid>
</Page>
23 changes: 23 additions & 0 deletions src/Wpf.Ui.Gallery/Views/Pages/Layout/LayoutPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.


using Wpf.Ui.Controls.Navigation;
using Wpf.Ui.Gallery.ViewModels.Pages.Layout;

namespace Wpf.Ui.Gallery.Views.Pages.Layout;

public partial class LayoutPage : INavigableView<LayoutViewModel>
{
public LayoutViewModel ViewModel { get; }

public LayoutPage(LayoutViewModel viewModel)
{
ViewModel = viewModel;
DataContext = this;

InitializeComponent();
}
}
22 changes: 22 additions & 0 deletions src/Wpf.Ui/Converters/AnimationFactorToValueConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Globalization;
using System.Windows.Data;

namespace Wpf.Ui.Converters;

public class AnimationFactorToValueConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values[0] is not double completeValue) return 0.0;
if (values[1] is not double factor) return 0.0;
if (parameter is "negative") factor = -factor;

return factor * completeValue;
}

public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
Loading

0 comments on commit 358f726

Please sign in to comment.