Пример #1
0
 private void SearchBtn_Click(object sender, RoutedEventArgs e)
 {
     if (!IsSearchBarOpen)
     {
         DoubleAnimation animation1 = new DoubleAnimation {
             To = 0, Duration = TimeSpan.FromMilliseconds(150)
         };
         animation1.Completed += (s, ar) =>
         {
             DoubleAnimation animation2 = new DoubleAnimation {
                 To = 60, Duration = TimeSpan.FromMilliseconds(100)
             };
             SearchTb.BeginAnimation(HeightProperty, animation2);
             SearchTb.Focus();
         };
         TitleNewsTb.BeginAnimation(HeightProperty, animation1);
         IsSearchBarOpen = true;
     }
     else
     {
         DoubleAnimation animation1 = new DoubleAnimation {
             To = 0, Duration = TimeSpan.FromMilliseconds(150)
         };
         animation1.Completed += (s, ar) =>
         {
             DoubleAnimation animation2 = new DoubleAnimation {
                 To = 60, Duration = TimeSpan.FromMilliseconds(100)
             };
             TitleNewsTb.BeginAnimation(HeightProperty, animation2);
         };
         SearchTb.BeginAnimation(HeightProperty, animation1);
         IsSearchBarOpen = false;
     }
 }
Пример #2
0
        private void SearchTb_LostFocus(object sender, RoutedEventArgs e)
        {
            DoubleAnimation animation1 = new DoubleAnimation {
                To = 0, Duration = TimeSpan.FromMilliseconds(150)
            };

            animation1.Completed += (s, ar) =>
            {
                DoubleAnimation animation2 = new DoubleAnimation {
                    To = 50, Duration = TimeSpan.FromMilliseconds(100)
                };
                TitleNewsTb.BeginAnimation(HeightProperty, animation2);
            };
            SearchTb.BeginAnimation(HeightProperty, animation1);
            SearchTb.Text = string.Empty;
            timer.Start();
        }