2010-08-17 89 views
0

控件模板用於自定義控件。WPF-如何在單擊時關閉控件模板中的彈出窗口?

我已經看到了這個問題: Why does a WPF Popup close when its background area is clicked?

但我無法弄清楚如何將命令綁定到控件模板的事件。我試過這個:

<Popup 
         Name="Popup" 
         Placement="Bottom" 
         IsOpen="{TemplateBinding IsDropDownOpen}" 
         AllowsTransparency="True" 
         Focusable="True" 
         PopupAnimation="Slide" 
         > 
         <i:Interaction.Triggers> 
          <i:EventTrigger EventName="MouseLeftButtonDown"> 
           <GalaSoft_MvvmLight_Command:EventToCommand Command="{TemplateBinding PopupClickedCommand}" PassEventArgsToCommand="True"/> 
          </i:EventTrigger> 
         </i:Interaction.Triggers> 
        </Popup> 

但是這個命令沒有觸發。

回答

0

嘗試PreviewMouseLeftButtonDown事件。

+0

它仍然沒有射擊。 – Justin 2010-08-17 18:57:05