private void OnDataContextPropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName != "IsFocused") { return; } PropertyInfo isFocusedProperty = sender.GetType().GetProperty("IsFocused"); if (isFocusedProperty == null) { return; } bool isFocused = (bool)isFocusedProperty.GetValue(sender); expandTimer.Enabled = isFocused; if (isFocused || !isExpanded) { return; } TagPanel.BeginAnimation(HeightProperty, colapseAnimation); isExpanded = false; }
/// <summary> /// 在 Tag Panel 上顯示 Tag。 /// </summary> /// <param name="notTagMessage">當 Tag 數量是 0 時要顯示的訊息。</param> private void DisplayTags <T, F>(T tags, string notTagMessage) where T : List <F> where F : GeneralTagRecord, new() { TagPanel.SuspendLayout(); List <PanelEx> tagpanels = new List <PanelEx>(); foreach (F each in tags) { tagpanels.Add(CreateTagItem(each.FullName, each.Color)); } //if (tags.Count <= 0) // tagpanels.Add(CreateTagItem(notTagMessage, Color.White)); CalculateTagSzie(tagpanels); TagPanel.Controls.Clear(); foreach (PanelEx each in tagpanels) { TagPanel.Controls.Add(each); } TagPanel.ResumeLayout(); }
private void OnExpandTimerElapsed(object sender, ElapsedEventArgs e) { Application.Current.Dispatcher?.Invoke(() => { TagPanel.BeginAnimation(HeightProperty, expandAnimation); isExpanded = true; }); }