2012-01-25 240 views
0

我爲我的應用使用WP7'Mango'SDK和Phone Toolkit。我有一個控件,其中包含ExpanderView。我使用一個模板爲ExpanderView的標題:WP7:按鈕點擊事件不會觸發,爲什麼?

<toolkit:ExpanderView.HeaderTemplate> 
    <DataTemplate> 
     <StackPanel Orientation="Horizontal"> 
      <TextBlock Text="{Binding Name}"/> 
      <Button Tap="ShowMoreTap"> 
       <Button.Template> 
        <ControlTemplate> 
         <TextBlock Text="show more..."/> 
        </ControlTemplate> 
       </Button.Template> 
      </Button> 
     </StackPanel> 
    </DataTemplate> 
</toolkit:ExpanderView.HeaderTemplate> 

背後的代碼:

private void ShowMoreTap(object sender, System.Windows.Input.GestureEventArgs e) 
{ 
    // Some logic here 
} 

我不想展開/摺疊ExpanderView當用戶點擊該按鈕時,我需要一些具體的行動在那裏。問題是ShowMoreTap事件永遠不會被觸發。

任何想法?
由於

回答

2

According to the source code的分接頭是通過ExpanderView處理,以使所述膨脹(或崩潰)

顯然,這個事件然後從未冒泡;它不是路由事件。

我看到兩個選項:

  1. 使用CodePlex從源代碼使ExpanderView的或定製的版本
  2. 停止使用ExpanderView,因爲你不希望擴大東西。您可以更輕鬆地切換到另一種風格類似的控件。記住:不要使用控件,因爲它看起來是你想要的,因爲它具有你需要的屬性和行爲。 WP7允許您設置任何控件的樣式。
+0

謝謝Erno!其實我不想拒絕從該控件的展開/摺疊選項。點擊此按鈕將向ExpanderView添加更多項目。之後,它將完全起到標準控制的作用。將嘗試製作定製版本。 –

相關問題