title: Integrate blink taskbar in Caliburn IWindowManager interface
body: <p>in order to blink taskbar, I found the following code: <a href="https://stackoverflow.com/a/5118285/1830639">https://stackoverflow.com/a/5118285/1830639</a>, which give me 2 extensions methods that I care about:</p>
  
  <pre><code>window.FlashWindow(5);
  window.StopFlashingWindow();
  </code></pre>
  
  <p>I'm creating some sort of chat messenger, and there are two interesting scenarios:</p>
  
  <ol>
  <li>Focus opened window when user clicks to chat an already opened chat. </li>
  <li>Blink opened window when a message arrives to an already opened chat.</li>
  </ol>
  
  <p>The <strong>1.</strong> I've accomplish with the following (<a href="https://stackoverflow.com/a/14765848/1830639">https://stackoverflow.com/a/14765848/1830639</a>):</p>
  
  <pre><code> public class MetroWindowManager : WindowManager
  {
      private IDictionary&lt;WeakReference, WeakReference&gt; windows = new Dictionary&lt;WeakReference, WeakReference&gt;();
  
      public override void ShowWindow(object rootModel, object context = null, IDictionary&lt;string, object&gt; settings = null)
      {
          NavigationWindow navWindow = null;
  
          if (Application.Current != null &amp;&amp; Application.Current.MainWindow != null)
          {
              navWindow = Application.Current.MainWindow as NavigationWindow;
          }
  
          if (navWindow != null)
          {
              var window = CreatePage(rootModel, context, settings);
              navWindow.Navigate(window);
          }
          else
          {
              var window = GetExistingWindow(rootModel);
              if (window == null)
              {
                  window = CreateWindow(rootModel, false, context, settings);
                  windows.Add(new WeakReference(rootModel), new WeakReference(window));
                  window.Show();
              }
              else
              {
                  window.Focus();
              }
          }
  
      }
  </code></pre>
  
  <p><strong>ChatManager</strong>:</p>
  
  <pre><code> public class ChatManager : IChatManager
  {
      private readonly IChatWindowSettings chatWindowSettings;
      private readonly IWindowManager windowManager;
      private IDictionary&lt;WeakReference, WeakReference&gt; chats;
  
      public ChatManager(IChatWindowSettings chatWindowSettings, IWindowManager windowManager)
      {
          this.chatWindowSettings = chatWindowSettings;
          this.windowManager = windowManager;
  
          chats = new Dictionary&lt;WeakReference, WeakReference&gt;();
      }
  
      public void OpenFor(Contact contact)
      {
          var settings = chatWindowSettings.Create();
          var viewModel = CreateOrGetViewModel(contact);
          windowManager.ShowWindow(viewModel, null, settings);
      }
  
      private ChatViewModel CreateOrGetViewModel(Contact contact)
      {
          ChatViewModel viewModel;
          if (!chats.Any(c =&gt; c.Key.IsAlive &amp;&amp; c.Key.Target == contact))
          {
              viewModel = new ChatViewModel(contact);
              chats.Add(new WeakReference(contact), new WeakReference(viewModel));
          }
          else
          {
              var chat = chats.Single(d =&gt; d.Key.Target == contact).Value;
              if (!chat.IsAlive)
              {
                  viewModel = new ChatViewModel(contact);
                  chats.Add(new WeakReference(contact), new WeakReference(viewModel));
              }
              else
              {
                  viewModel = chat.Target as ChatViewModel;
              }
          }
  
          return viewModel;
      }
  </code></pre>
  
  <p>As you can see, I'm relying on <strong><em>IWindowManager</em></strong> interface. Now for the <strong>2.</strong> I thought of implementing an extension method on <em>IWindowManager</em> <em>Blink()</em>, however in the extension method I don't have access to the <em>WeakReferences</em> (<em>windows</em> variable) I've created in the <strong>MetroWindowManager</strong>:</p>
  
  <pre><code> public void MessageFor(Contact contact, IChatMessage message)
      {
          var viewModel = CreateOrGetViewModel(contact);
          windowManager.Blink(viewModel);
      }
  </code></pre>
  
  <p>Any ideas?</p>