Skip to content

Commit

Permalink
feat: 窗体页面标题使用动态资源
Browse files Browse the repository at this point in the history
  • Loading branch information
SlimeNull committed Mar 23, 2024
1 parent 08105fa commit fea2b70
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions OpenGptChat.Avalonia/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml.MarkupExtensions;
using Microsoft.Extensions.DependencyInjection;
using OpenGptChat.Strings;
using OpenGptChat.Views.Pages;
Expand Down Expand Up @@ -54,10 +55,9 @@ public void OnNext(AvaloniaPropertyChangedEventArgs<Control?> e)
mainWindow.ConfigPageButtons.IsVisible = newValue is ConfigPage;

if (newValue is not null &&
newValue.Tag is not null &&
StringResources.Instance.TryGetResource(newValue.Tag, null, out var title))
newValue.Tag is not null)
{
mainWindow.PageTitle.Text = title as string;
mainWindow.PageTitle.Bind(TextBlock.TextProperty, new DynamicResourceExtension(newValue.Tag));
}
}
else
Expand Down

0 comments on commit fea2b70

Please sign in to comment.