WPF: How do I make a custom modal dialog flash?

后端 未结 2 1763
攒了一身酷
攒了一身酷 2021-01-19 00:24

Normally when you open a Modal Dialog and try to click on it\'s parent window the Modal Dialog\'s titlebar flashes. When creating a custom, borderless, chromeless, window in

2条回答
  •  被撕碎了的回忆
    2021-01-19 01:08

    If you didn't exactly find what you're looking for, there is a workaround which involves not using a modal window at all.

    Here's how you can do it:

    1. create a user control named MainContentUC and put the contents of MainWindow in it
    2. create another user control named MessageBoxUC and put the contents of your messagebox in it

      
          
              
              
                  
                      
                          
                              
                          
                      
                  
              
          
      
      
    3. add a boolean dependency property in MessageBoxUC named IsOpen (default=false)

    4. write xaml code of your main window as follows:

      
          
              
              
          
      
      

    This way when the MessageBoxUC is open it will block MainContentsUC from being clicked. and when you click on the back area (where color is set to #4FFF) the trigger runs the storyboard and it blinks.

    if you have several windows you can implement different control templates and choose between them using a template selector. so instead of you will have

提交回复
热议问题