Explorar o código

Fix scroll viewer visibility.

Bebo-Maker %!s(int64=3) %!d(string=hai) anos
pai
achega
734d116bfe
Modificáronse 1 ficheiros con 20 adicións e 19 borrados
  1. 20 19
      QuestPDF.Previewer/PreviewerWindow.axaml.cs

+ 20 - 19
QuestPDF.Previewer/PreviewerWindow.axaml.cs

@@ -23,44 +23,45 @@ namespace QuestPDF.Previewer
             get => GetValue(DocumentProperty);
             set => SetValue(DocumentProperty, value);
         }
-        
-        
-        
-        public static readonly StyledProperty<float> CurrentScrollProperty = AvaloniaProperty.Register<PreviewerControl, float>(nameof(CurrentScroll));
-        
+
+        public static readonly StyledProperty<float> CurrentScrollProperty =
+            AvaloniaProperty.Register<PreviewerWindow, float>(nameof(CurrentScroll));
+
         public float CurrentScroll
         {
             get => GetValue(CurrentScrollProperty);
             set => SetValue(CurrentScrollProperty, value);
         }
-        
-        public static readonly StyledProperty<float> ScrollViewportSizeProperty = AvaloniaProperty.Register<PreviewerControl, float>(nameof(ScrollViewportSize));
-        
+
+        public static readonly StyledProperty<float> ScrollViewportSizeProperty =
+            AvaloniaProperty.Register<PreviewerWindow, float>(nameof(ScrollViewportSize));
+
         public float ScrollViewportSize
         {
             get => GetValue(ScrollViewportSizeProperty);
             set => SetValue(ScrollViewportSizeProperty, value);
         }
-        
-        public static readonly StyledProperty<bool> VerticalScrollbarVisibleProperty = AvaloniaProperty.Register<PreviewerControl, bool>(nameof(VerticalScrollbarVisible));
-        
+
+        public static readonly StyledProperty<bool> VerticalScrollbarVisibleProperty =
+            AvaloniaProperty.Register<PreviewerWindow, bool>(nameof(VerticalScrollbarVisible));
+
         public bool VerticalScrollbarVisible
         {
             get => GetValue(VerticalScrollbarVisibleProperty);
             set => SetValue(VerticalScrollbarVisibleProperty, value);
         }
-        
-        
+
         public PreviewerWindow()
         {
             InitializeComponent();
 
-            ScrollViewportSizeProperty.Changed.Subscribe(_ =>
-            {
-                VerticalScrollbarVisible = ScrollViewportSize < 1;
-                Debug.WriteLine($"Scrollbar visible: {VerticalScrollbarVisible}");
-            });
-            
+            ScrollViewportSizeProperty.Changed
+                .Subscribe(e => Dispatcher.UIThread.Post(() =>
+                {
+                    VerticalScrollbarVisible = e.NewValue.Value < 1;
+                    Debug.WriteLine($"Scrollbar visible: {VerticalScrollbarVisible}");
+                }));
+
             // this.FindControl<Button>("GeneratePdf")
             //     .Click += (_, _) => _ = PreviewerUtils.SavePdfWithDialog(Document, this);