Skip to content

Commit

Permalink
Merge pull request #501 from huynhsontung/fix-invalid-xaml-resources
Browse files Browse the repository at this point in the history
fix: Lively selector crash due to invalid XAML resource
  • Loading branch information
huynhsontung authored Dec 3, 2024
2 parents 32eb980 + 386abc2 commit 30ca233
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public sealed partial class LivelyWallpaperSelectorViewModel : ObservableRecipie
private readonly ILivelyWallpaperService _wallpaperService;
private readonly IFilesService _filesService;
private readonly ISettingsService _settingsService;
private readonly DispatcherQueue _dispatcherQueue;

public LivelyWallpaperSelectorViewModel(ILivelyWallpaperService wallpaperService, IFilesService filesService, ISettingsService settingsService,
string defaultTitle, string defaultPreviewPath) : this(wallpaperService, filesService, settingsService)
Expand All @@ -55,6 +56,7 @@ public LivelyWallpaperSelectorViewModel(ILivelyWallpaperService wallpaperService
_wallpaperService = wallpaperService;
_filesService = filesService;
_settingsService = settingsService;
_dispatcherQueue = DispatcherQueue.GetForCurrentThread();
}

public async Task InitializeVisualizers()
Expand All @@ -77,7 +79,7 @@ public async Task LoadVisualizers()

public void Receive(PropertyChangedMessage<LivelyWallpaperModel?> message)
{
SelectedVisualizer = message.NewValue;
_dispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, () => SelectedVisualizer = message.NewValue);
}

partial void OnSelectedVisualizerChanged(LivelyWallpaperModel? value)
Expand Down
3 changes: 1 addition & 2 deletions Screenbox/Controls/LivelyWallpaperSelector.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
<Grid
Width="112"
Height="96"
CornerRadius="{StaticResource GridViewItemCornerRadius}"
FlowDirection="LeftToRight"
ToolTipService.ToolTip="{x:Bind Model.Title, FallbackValue={x:Null}}">
<Grid.Background>
Expand All @@ -83,7 +82,7 @@
Background="{ThemeResource AcrylicInAppFillColorDefaultBrush}"
BorderBrush="{ThemeResource ControlStrokeColorForStrongFillWhenOnImageBrush}"
BorderThickness="1"
CornerRadius="{StaticResource GridViewItemCornerRadius}"
CornerRadius="4"
ToolTipService.ToolTip="{strings:Resources Key=PoweredByLivelyWallpaper}"
Visibility="{x:Bind Path, Converter={StaticResource StringVisibilityConverter}}">
<Image
Expand Down
2 changes: 2 additions & 0 deletions Screenbox/InvaidXamlResources.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# DO NOT USE THE FOLLOWING RESOURCES IN XAML FILES. THEY ARE NOT GENERALLY AVAILABLE.
GridViewItemCornerRadius
1 change: 1 addition & 0 deletions Screenbox/Screenbox.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@
<None Include="Controls\Animations\AnimatedPlayingVisualSource.json" />
<None Include="Package.StoreAssociation.xml" />
<None Include="packages.lock.json" />
<None Include="InvaidXamlResources.txt" />
<Content Include="Properties\Default.rd.xml" />
<None Include="Secrets.cs.template" />
</ItemGroup>
Expand Down

0 comments on commit 30ca233

Please sign in to comment.