Browse Source

Fix scroll viewer visibility.

Bebo-Maker 3 years ago
parent
commit
734d116bfe
1 changed files with 20 additions and 19 deletions
  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);
             get => GetValue(DocumentProperty);
             set => SetValue(DocumentProperty, value);
             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
         public float CurrentScroll
         {
         {
             get => GetValue(CurrentScrollProperty);
             get => GetValue(CurrentScrollProperty);
             set => SetValue(CurrentScrollProperty, value);
             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
         public float ScrollViewportSize
         {
         {
             get => GetValue(ScrollViewportSizeProperty);
             get => GetValue(ScrollViewportSizeProperty);
             set => SetValue(ScrollViewportSizeProperty, value);
             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
         public bool VerticalScrollbarVisible
         {
         {
             get => GetValue(VerticalScrollbarVisibleProperty);
             get => GetValue(VerticalScrollbarVisibleProperty);
             set => SetValue(VerticalScrollbarVisibleProperty, value);
             set => SetValue(VerticalScrollbarVisibleProperty, value);
         }
         }
-        
-        
+
         public PreviewerWindow()
         public PreviewerWindow()
         {
         {
             InitializeComponent();
             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")
             // this.FindControl<Button>("GeneratePdf")
             //     .Click += (_, _) => _ = PreviewerUtils.SavePdfWithDialog(Document, this);
             //     .Click += (_, _) => _ = PreviewerUtils.SavePdfWithDialog(Document, this);