File tree Expand file tree Collapse file tree 4 files changed +49
-2
lines changed
Expand file tree Collapse file tree 4 files changed +49
-2
lines changed Original file line number Diff line number Diff line change 1919 <!-- Converters -->
2020 <converters : SheetPillLocationVisibilityConverter x : Key =" SheetPillLocationToVisibilityConverter" />
2121 <converters : SheetPullLocationPaddingConverter x : Key =" SheetPillLocationPaddingConverter" />
22+ <converters : SheetScrollDirectionConverter x : Key =" SheetScrollDirectionConverter" />
2223
2324 <!-- Defaults -->
2425 <system : TimeSpan x : Key =" SheetAnimationDuration" >0:0:0.2</system : TimeSpan >
128129 Padding =" {TemplateBinding PillLocation, Converter={StaticResource SheetPillLocationPaddingConverter}}" >
129130 <ScrollViewer
130131 Name =" PART_ScrollViewer"
131- HorizontalScrollBarVisibility =" Disabled "
132- VerticalScrollBarVisibility =" Auto " >
132+ HorizontalScrollBarVisibility =" {TemplateBinding ScrollDirection, Converter={StaticResource SheetScrollDirectionConverter}, ConverterParameter=Horizontal} "
133+ VerticalScrollBarVisibility =" {TemplateBinding ScrollDirection, Converter={StaticResource SheetScrollDirectionConverter}, ConverterParameter=Vertical} " >
133134 <ContentPresenter
134135 Name =" PART_ContentPresenter"
135136 TextWrapping =" Wrap"
Original file line number Diff line number Diff line change @@ -82,6 +82,15 @@ public SheetPillLocation PillLocation
8282 public static readonly StyledProperty < IBrush > PillColorProperty = AvaloniaProperty . Register < Sheet , IBrush > (
8383 nameof ( PillColor ) ) ;
8484
85+ public static readonly StyledProperty < SheetScrollDirection > ScrollDirectionProperty = AvaloniaProperty . Register < Sheet , SheetScrollDirection > (
86+ nameof ( ScrollDirection ) , defaultValue : SheetScrollDirection . Vertical ) ;
87+
88+ public SheetScrollDirection ScrollDirection
89+ {
90+ get => GetValue ( ScrollDirectionProperty ) ;
91+ set => SetValue ( ScrollDirectionProperty , value ) ;
92+ }
93+
8594 public IBrush PillColor
8695 {
8796 get => GetValue ( PillColorProperty ) ;
Original file line number Diff line number Diff line change 1+ namespace Jc . PopupView . Avalonia . Controls ;
2+
3+ [ Flags ]
4+ public enum SheetScrollDirection
5+ {
6+ None = 0x0 ,
7+ Vertical = 0x1 ,
8+ Horizontal = 0x2 ,
9+ Both = Vertical | Horizontal
10+ }
Original file line number Diff line number Diff line change 1+ using System . Globalization ;
2+ using Avalonia . Controls . Primitives ;
3+ using Avalonia . Data . Converters ;
4+ using Jc . PopupView . Avalonia . Controls ;
5+
6+ namespace Jc . PopupView . Avalonia . Converters ;
7+
8+ public class SheetScrollDirectionConverter : IValueConverter
9+ {
10+ public object ? Convert ( object ? value , Type targetType , object ? parameter , CultureInfo culture )
11+ {
12+ if ( value is SheetScrollDirection direction && Enum . TryParse < SheetScrollDirection > ( parameter as string , true , out var paramDirection ) )
13+ {
14+ if ( direction == SheetScrollDirection . Both || direction == paramDirection )
15+ {
16+ return ScrollBarVisibility . Auto ;
17+ }
18+ }
19+
20+ return ScrollBarVisibility . Disabled ;
21+ }
22+
23+ public object ? ConvertBack ( object ? value , Type targetType , object ? parameter , CultureInfo culture )
24+ {
25+ throw new NotImplementedException ( ) ;
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments