public MemoRecorderPanel() { InitializeComponent(); try { _viewModel = new MemoRecorderViewModel(); } catch { } this.DataContext = _viewModel; _timeoutTimer = new DispatcherTimer(); _timeoutTimer.Interval = TimeSpan.FromMinutes(MaxTimeout); _timeoutTimer.Tick += new EventHandler(OnTimeoutTimerTick); _approachTimer = new DispatcherTimer(); _approachTimer.Tick += new EventHandler(OnApproachTimerTick); for (int i = 0; i < BarNumber; ++i) { Bar bar = new Bar() { Margin = new Thickness(8, 0, 0, 0), Height = 220 }; BarsStackPanel.Children.Add(bar); } timeTextBlock.Foreground = BlackBrush; }