在窗口隐藏(`Visibility.Hidden`)期间实例化的 `hc:Divider` 分隔线渲染宽度为 0

作者: ABA2396创建于 2026年8月17日更新于 2026年8月17日

using System; using System.Windows; using System.Windows.Threading; namespace DividerTest; public partial class MainWindow { public MainWindow() { InitializeComponent(); // Add the first divider after 1 second, then minimize and hide the window (simulate minimizing to the tray) var t1 = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) }; t1.Tick += (s, e) => { t1.Stop(); LogList.Items.Add("A: Added immediately after hiding"); WindowState = WindowState.Minimized; ShowInTaskbar = false; Visibility = Visibility.Hidden; // Add another divider after 2 seconds (the window is still hidden) var t2 = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) }; t2.Tick += (s, e) => { t2.Stop(); LogList.Items.Add("B: Added after 2 seconds"); WindowState = WindowState.Normal; ShowInTaskbar = true; Visibility = Visibility.Visible; } t2.Start(); } t1.Start(); } }

内容来源: HandyOrg/HandyControl