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
5 changes: 3 additions & 2 deletions src/Jc.PopupView.Avalonia/ControlThemes/Sheet.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<!-- Converters -->
<converters:SheetPillLocationVisibilityConverter x:Key="SheetPillLocationToVisibilityConverter" />
<converters:SheetPullLocationPaddingConverter x:Key="SheetPillLocationPaddingConverter" />
<converters:SheetScrollDirectionConverter x:Key="SheetScrollDirectionConverter" />

<!-- Defaults -->
<system:TimeSpan x:Key="SheetAnimationDuration">0:0:0.2</system:TimeSpan>
Expand Down Expand Up @@ -128,8 +129,8 @@
Padding="{TemplateBinding PillLocation, Converter={StaticResource SheetPillLocationPaddingConverter}}">
<ScrollViewer
Name="PART_ScrollViewer"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto">
HorizontalScrollBarVisibility="{TemplateBinding ScrollDirection, Converter={StaticResource SheetScrollDirectionConverter}, ConverterParameter=Horizontal}"
VerticalScrollBarVisibility="{TemplateBinding ScrollDirection, Converter={StaticResource SheetScrollDirectionConverter}, ConverterParameter=Vertical}">
<ContentPresenter
Name="PART_ContentPresenter"
TextWrapping="Wrap"
Expand Down
9 changes: 9 additions & 0 deletions src/Jc.PopupView.Avalonia/Controls/Sheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ public SheetPillLocation PillLocation
public static readonly StyledProperty<IBrush> PillColorProperty = AvaloniaProperty.Register<Sheet, IBrush>(
nameof(PillColor));

public static readonly StyledProperty<SheetScrollDirection> ScrollDirectionProperty = AvaloniaProperty.Register<Sheet, SheetScrollDirection>(
nameof(ScrollDirection), defaultValue: SheetScrollDirection.Vertical);

public SheetScrollDirection ScrollDirection
{
get => GetValue(ScrollDirectionProperty);
set => SetValue(ScrollDirectionProperty, value);
}

public IBrush PillColor
{
get => GetValue(PillColorProperty);
Expand Down
10 changes: 10 additions & 0 deletions src/Jc.PopupView.Avalonia/Controls/Sheet/SheetScrollDirection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Jc.PopupView.Avalonia.Controls;

[Flags]
public enum SheetScrollDirection
{
None = 0x0,
Vertical = 0x1,
Horizontal = 0x2,
Both = Vertical | Horizontal
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Globalization;
using Avalonia.Controls.Primitives;
using Avalonia.Data.Converters;
using Jc.PopupView.Avalonia.Controls;

namespace Jc.PopupView.Avalonia.Converters;

public class SheetScrollDirectionConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is SheetScrollDirection direction && Enum.TryParse<SheetScrollDirection>(parameter as string, true, out var paramDirection))
{
if (direction == SheetScrollDirection.Both || direction == paramDirection)
{
return ScrollBarVisibility.Auto;
}
}

return ScrollBarVisibility.Disabled;
}

public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
Loading