Blink tab header on receiving event

前端 未结 1 1432
半阙折子戏
半阙折子戏 2021-01-07 04:13

I have a tab based chat application, which a user can chat with several people in different tab items. I want to notify the user of incoming messages by blinking the tab hea

1条回答
  •  清歌不尽
    2021-01-07 04:50

    You need to create a style for the header that includes an animation to flash/blink the header foreground. Once you have this you can then apply this when ever needed.

    The example below does this. You may want to modify this so set the background instead to make the whole tab flash not just the TabItems text.

    
    
        
            
        
    
        
    
            
                
                
                
             
    
            
    
                
                two
                
                
    
             
    
    
        
    
    

    Then in the c# code you can set the style when ever needed:

       private void StartFlash_Click(object sender, RoutedEventArgs e)
            {
                TabItem ti = (TabItem)this.FindName(userInput.Text);
    
                if (ti != null)
                {
                    ti.SetValue(Control.StyleProperty, (Style)this.Resources["FlashingHeader"]);
                }
    
            }
    
            private void StopFlash_Click(object sender, RoutedEventArgs e)
            {
                TabItem ti = (TabItem)this.FindName(userInput.Text);
    
                if (ti != null)
                {
                    ti.Style = null;
                }
            }
    

    0 讨论(0)
提交回复
热议问题