@@ -1461,9 +1461,15 @@ public override Color BackColor
14611461 [ AllowNull ]
14621462 public override Font Font
14631463 {
1464- get => base . Font ;
1464+ get => GetStateCommonFont ( ) ?? base . Font ;
14651465
1466- set => base . Font = value ! ;
1466+ set
1467+ {
1468+ // Always set base.Font to ensure consistency
1469+ base . Font = value ! ;
1470+ // Also try to set StateCommon font, but don't fail if it's not available
1471+ SetStateCommonFont ( value ) ;
1472+ }
14671473 }
14681474
14691475 /// <summary>
@@ -2435,6 +2441,54 @@ protected virtual void OnHoverSelectionChanged(HoveredSelectionChangedEventArgs
24352441 /// </summary>
24362442 /// <param name="e"></param>
24372443 protected virtual void OnToolTipNeeded ( ToolTipNeededEventArgs e ) => ToolTipNeeded ? . Invoke ( this , e ) ;
2444+
2445+ /// <summary>
2446+ /// Gets the font from StateCommon.ComboBox.Content.Font safely, handling design mode serialization issues.
2447+ /// </summary>
2448+ /// <returns>The font from StateCommon, or null if not available or during problematic design time access.</returns>
2449+ protected virtual Font ? GetStateCommonFont ( )
2450+ {
2451+ try
2452+ {
2453+ // Use null-conditional operators to safely access nested properties
2454+ // This prevents issues during design time serialization when StateCommon might not be fully initialized
2455+ return StateCommon . ComboBox . Content ? . Font ;
2456+ }
2457+ catch
2458+ {
2459+ // If StateCommon is not fully initialized or there's a serialization issue,
2460+ // return null to fall back to base.Font
2461+ return null ;
2462+ }
2463+ }
2464+
2465+ /// <summary>
2466+ /// Sets the font to StateCommon.ComboBox.Content.Font safely, handling design mode serialization issues.
2467+ /// </summary>
2468+ /// <param name="value">The font value to set.</param>
2469+ /// <returns>True if the font was set to StateCommon, false to fall back to base.Font.</returns>
2470+ protected virtual bool SetStateCommonFont ( Font ? value )
2471+ {
2472+ try
2473+ {
2474+ // Use null-conditional operators to safely access nested properties
2475+ // This prevents issues during design time serialization when StateCommon might not be fully initialized
2476+ if ( StateCommon . ComboBox ? . Content != null )
2477+ {
2478+ StateCommon . ComboBox . Content . Font = value ;
2479+
2480+ return true ;
2481+ }
2482+ }
2483+ catch
2484+ {
2485+ // If StateCommon is not fully initialized or there's a serialization issue,
2486+ // return false to fall back to base.Font
2487+ }
2488+
2489+ return false ;
2490+ }
2491+
24382492 // ReSharper restore VirtualMemberNeverOverridden.Global
24392493 #endregion
24402494
0 commit comments