From 6751942179585433c153d4741234ef28faf0c126 Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Sun, 17 Aug 2025 14:30:03 +0800
Subject: [PATCH] Use Binding instead of RelativeResource for code quality
---
.../Views/PreviewPanel.xaml | 32 +++++++++----------
.../Views/PreviewPanel.xaml.cs | 27 ++++++++--------
2 files changed, 29 insertions(+), 30 deletions(-)
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml
index a43297951..4479571e3 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml
@@ -24,14 +24,14 @@
MaxWidth="96"
MaxHeight="96"
Margin="5 12 8 0"
- Source="{Binding PreviewImage, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" />
+ Source="{Binding PreviewImage, IsAsync=True, Mode=OneWay}" />
@@ -47,7 +47,7 @@
+ Text="{Binding FilePath, Mode=OneTime}" />
-
-
-
+
+
+
@@ -70,7 +70,7 @@
-
+
@@ -88,7 +88,7 @@
Style="{DynamicResource PreviewItemSubTitleStyle}"
Text="{DynamicResource FileSize}"
TextWrapping="Wrap"
- Visibility="{Binding FileSizeVisibility, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" />
+ Visibility="{Binding FileSizeVisibility, Mode=OneTime}" />
+ Visibility="{Binding FileSizeVisibility, Mode=OneTime}" />
+ Visibility="{Binding CreatedAtVisibility, Mode=OneTime}" />
+ Visibility="{Binding CreatedAtVisibility, Mode=OneTime}" />
+ Visibility="{Binding LastModifiedAtVisibility, Mode=OneTime}" />
+ Visibility="{Binding LastModifiedAtVisibility, Mode=OneTime}" />
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs
index c931a014e..4dd0588ee 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs
@@ -23,21 +23,20 @@ public partial class PreviewPanel : UserControl
public string FilePath { get; }
public string FileName { get; }
- public string FileSize { get; private set; } = Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown");
- public string CreatedAt { get; } = "";
- public string LastModifiedAt { get; } = "";
- private ImageSource _previewImage = new BitmapImage();
- private Settings Settings { get; }
- public ImageSource PreviewImage
- {
- get => _previewImage;
- private set
- {
- _previewImage = value;
- OnPropertyChanged();
- }
- }
+ [ObservableProperty]
+ private string _fileSize = Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown");
+
+ [ObservableProperty]
+ private string _createdAt = "";
+
+ [ObservableProperty]
+ private string _lastModifiedAt = "";
+
+ [ObservableProperty]
+ private ImageSource _previewImage = new BitmapImage();
+
+ private Settings Settings { get; }
public Visibility FileSizeVisibility => Settings.ShowFileSizeInPreviewPanel
? Visibility.Visible