소스 검색

Fix scroll viewer visibility.

Bebo-Maker 3 년 전
부모
커밋
734d116bfe
1개의 변경된 파일20개의 추가작업 그리고 19개의 파일을 삭제
  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);