fix: 修正MainView初始化时某些元素找不到导致引发NullReference异常的问题。

This commit is contained in:
SL 2026-06-05 09:59:58 +08:00
parent 187984f5b9
commit 039d1c77db

View File

@ -1075,6 +1075,7 @@ namespace SicUI.Client
{ {
var scPath = $"PM.{_currentMenuItem.System}.BackgroundColor"; var scPath = $"PM.{_currentMenuItem.System}.BackgroundColor";
var scConfig = QueryDataClient.Instance.Service.GetConfig(scPath); var scConfig = QueryDataClient.Instance.Service.GetConfig(scPath);
if (scConfig == null) return;
var hexColor = scConfig.ToString(); var hexColor = scConfig.ToString();
try try
{ {
@ -1094,7 +1095,6 @@ namespace SicUI.Client
UpdatePMPageBackground(Colors.Transparent); UpdatePMPageBackground(Colors.Transparent);
UpdateMainMenuBackground(); UpdateMainMenuBackground();
} }
} }
else else
{ {
@ -1374,12 +1374,12 @@ namespace SicUI.Client
if (menuInfo.System is "PM1" or "PM2") if (menuInfo.System is "PM1" or "PM2")
{ {
var rect = FindVisualChildByName<Rectangle>(container, "InnerBG"); var rect = FindVisualChildByName<Rectangle>(container, "InnerBG");
rect.Fill = menuInfo.Selected rect?.Fill = menuInfo.Selected
? BgActiveContent ? BgActiveContent
: new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF346294")); : new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF346294"));
var bgBorder = FindVisualChildByName<Border>(container, "BG"); var bgBorder = FindVisualChildByName<Border>(container, "BG");
bgBorder.Background = menuInfo.Selected bgBorder?.Background = menuInfo.Selected
? BgActiveContent ? BgActiveContent
: new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF346294")); : new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF346294"));