Browse Source

Fix checkpoint folder cards scroll

pull/5/head
Ionite 1 year ago
parent
commit
8ec2753677
No known key found for this signature in database
  1. 53
      StabilityMatrix/CheckpointManagerPage.xaml
  2. 22
      StabilityMatrix/CheckpointManagerPage.xaml.cs

53
StabilityMatrix/CheckpointManagerPage.xaml

@ -18,13 +18,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Page.Resources>
<DataTemplate DataType="{x:Type models:CheckpointFile}" x:Key="CheckpointCardDataTemplate">
<ui:Card Width="256">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="0.2*" />
</Grid.ColumnDefinitions>
<DataTemplate DataType="{x:Type models:CheckpointFile}" x:Key="CheckpointFileDataTemplate">
<ui:CardAction Height="96" Width="240">
<StackPanel Orientation="Vertical">
<ui:Image
CornerRadius="4"
@ -47,25 +42,11 @@
Text="{Binding FileName}"
VerticalAlignment="Center" />
</StackPanel>
<ui:DropDownButton Grid.Column="1" Margin="16,0,0,0">
<ui:DropDownButton.Style>
<Style BasedOn="{StaticResource {x:Type ui:DropDownButton}}" TargetType="{x:Type ui:DropDownButton}">
<Setter Property="Visibility" Value="Hidden" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ui:Card}}}" Value="True">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</ui:DropDownButton.Style>
<ui:SymbolIcon Symbol="ChevronDown24" />
</ui:DropDownButton>
</Grid>
</ui:Card>
</ui:CardAction>
</DataTemplate>
<DataTemplate DataType="{x:Type models:CheckpointFolder}" x:Key="CheckpointFolderCardGridDataTemplate">
<ui:CardExpander
<DataTemplate DataType="{x:Type models:CheckpointFolder}" x:Key="CheckpointFolderGridDataTemplate">
<Expander
AllowDrop="True"
Drop="FolderCard_OnDrop"
Header="{Binding Title}"
@ -76,28 +57,38 @@
PreviewDragOver="FolderCard_OnPreviewDragOver"
PreviewDrop="FolderCard_OnPreviewDrop">
<ui:VirtualizingGridView
ItemTemplate="{StaticResource CheckpointCardDataTemplate}"
ItemTemplate="{StaticResource CheckpointFileDataTemplate}"
ItemsSource="{Binding CheckpointFiles}"
Padding="5"
PreviewMouseWheel="VirtualizingGridView_OnPreviewMouseWheel"
SpacingMode="StartAndEndOnly" />
</ui:CardExpander>
</Expander>
</DataTemplate>
<DataTemplate DataType="{x:Type models:CheckpointFolder}" x:Key="CheckpointFolderCardDataTemplate">
<DataTemplate DataType="{x:Type models:CheckpointFolder}" x:Key="CheckpointFolderDataTemplate">
<ContentControl Content="{Binding}">
<ContentControl.Style>
<Style TargetType="{x:Type ContentControl}">
<Setter Property="ContentTemplate" Value="{StaticResource CheckpointFolderCardGridDataTemplate}" />
<Setter Property="ContentTemplate" Value="{StaticResource CheckpointFolderGridDataTemplate}" />
</Style>
</ContentControl.Style>
</ContentControl>
</DataTemplate>
</Page.Resources>
<!-- Option Cards -->
<!-- Folder Cards -->
<ui:DynamicScrollViewer
CanContentScroll="True"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto">
<Grid>
<StackPanel Orientation="Vertical">
<ItemsControl
HorizontalAlignment="Stretch"
ItemTemplate="{StaticResource CheckpointFolderCardGridDataTemplate}"
ItemsSource="{Binding CheckpointFolders}"
ItemTemplate="{StaticResource CheckpointFolderGridDataTemplate}"
ItemsSource="{Binding CheckpointFolders, Mode=OneWay}"
Margin="16,16,16,16" />
</StackPanel>
</Grid>
</ui:DynamicScrollViewer>
</Page>

22
StabilityMatrix/CheckpointManagerPage.xaml.cs

@ -2,6 +2,7 @@
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Effects;
using StabilityMatrix.ViewModels;
@ -74,4 +75,25 @@ public partial class CheckpointManagerPage : Page
{
await viewModel.OnLoaded();
}
/// <summary>
/// Bubbles the mouse wheel event up to the parent.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void VirtualizingGridView_OnPreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
if (e.Handled) return;
e.Handled = true;
var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta)
{
RoutedEvent = MouseWheelEvent,
Source = sender
};
if (((Control)sender).Parent is UIElement parent)
{
parent.RaiseEvent(eventArg);
}
}
}

Loading…
Cancel
Save