/// <summary> /// 리스트 박스 크기 변경 /// </summary> /// <param name="listBox"></param> /// <param name="count"></param> public void SetListBoxHeight(int idx, int count) { Border groupBox = this.FindName(string.Format("{0}GroupBox", listNames[idx])) as Border; ListBox listBox = this.FindName(string.Format("{0}ListBox", listNames[idx])) as ListBox; listBox.BeginAnimation(ListBox.HeightProperty, null); double fromHeight = listBox.ActualHeight; double toHeight = count * 40; if (expandQuestGroup[idx] == false || groupBox.IsEnabled == false) { toHeight = 0; } Animations.ChangeHeight.From = fromHeight; Animations.ChangeHeight.To = toHeight; listBox.BeginAnimation(ListBox.HeightProperty, Animations.ChangeHeight); }
public static void AnimateListBox(ListBox lb, System.Windows.Thickness toThickness) { ThicknessAnimation animation = new ThicknessAnimation() { AccelerationRatio = .9, Duration = TimeSpan.FromSeconds(.3), To = toThickness }; lb.BeginAnimation(ListBox.MarginProperty, animation); }
/// <summary> /// Shows the list of suggestions. If the current word is not misspelled /// this method does nothing. /// </summary> public void ShowSuggestions() { if (AreSuggestionsVisible || !IsCurrentWordMisspelled) { return; } // If this method was called by external code, // the list of suggestions will not be populated yet. if (suggestionList.ItemsSource == null) { AttemptToShowSuggestions(); return; } AdornerLayer layer = AdornerLayer.GetAdornerLayer(this); if (layer == null) { return; } // Position the adorner beneath the misspelled word. int idx = FindBeginningOfCurrentWord(); Rect rect = GetRectFromCharacterIndex(idx); adorner.SetOffsets(rect.Left, rect.Bottom); // Add the adorner into the adorner layer. layer.Add(adorner); // Since the ListBox might have a new set of items but has not // rendered yet, we force it to calculate its metrics so that // the height animation has a sensible target value. suggestionList.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); suggestionList.Arrange(new Rect(new Point(), suggestionList.DesiredSize)); // Animate the ListBox's height to the natural value. var anim = new DoubleAnimation { From = 0.0, To = suggestionList.ActualHeight, Duration = new Duration(TimeSpan.FromMilliseconds(200)), FillBehavior = FillBehavior.Stop }; suggestionList.BeginAnimation(HeightProperty, anim); areSuggestionsVisible = true; }
/// <summary> /// 리스트 박스 크기 변경 /// </summary> /// <param name="idx"></param> /// <param name="count"></param> public void SetListBoxHeight(int idx, int count) { Dispatcher.Invoke(() => { Border groupBox = this.FindName(string.Format("Echelon{0}GroupBox", idx)) as Border; ListBox listBox = this.FindName(string.Format("Echelon{0}ListBox", idx)) as ListBox; if (groupBox != null && listBox != null) { DoubleAnimation ChangeHeight = new DoubleAnimation { From = 0, To = 0, Duration = new Duration(TimeSpan.FromMilliseconds(300)), EasingFunction = new CircleEase() { EasingMode = EasingMode.EaseOut }, }; double fromHeight = listBox.ActualHeight; double toHeight = count * 40; listBox.Visibility = Visibility.Visible; //listBox.BeginAnimation(ListBox.HeightProperty, null); if (Config.Echelon.expand[idx - 1] == false || groupBox.IsEnabled == false) { toHeight = 0; } ChangeHeight.From = fromHeight; ChangeHeight.To = toHeight; //if (toHeight == 0) //{ // ChangeHeight.Completed += (sender, args) => // { // listBox.Visibility = Visibility.Collapsed; // }; //} listBox.BeginAnimation(ListBox.HeightProperty, ChangeHeight); } }); }