2016-01-23 195 views
-4

我要刪除選定的堆棧面板,但是當我選擇的StackPanel它給予例外System.NullReferenceException的Windows Phone 8.1

  <ListBox x:Name="listbox1" Background="{x:Null}"   
        Margin="-2,51,-4,647" BorderBrush="{x:Null}"> 
       <ListBox.ItemTemplate> 
        <DataTemplate> 
         <StackPanel Tag="{Binding Weight_ID}" 
            Tapped="StackPanel_Tapped" > 

         <StackPanel Orientation="Horizontal"> 
           <TextBlock x:Name="date" Text=" Date">      
           </TextBlock> 
           <TextBlock Text="{Binding Date_}" > 
         </StackPanel>  
         </StackPanel> 
         </DataTemplate> 
         </ListBox.ItemTemplate> 
         </ListBox> 


    private void StackPanel_Tapped(object sender, TappedRoutedEventArgs e) 
    { 

     string id = (((e.OriginalSource) as TextBlock).Tag).ToString(); 
    } 
+0

而你的問題是? http://stackoverflow.com/help/how-to-ask – Carlo

+0

嘗試從ListBox替換爲ListVIew並使用ItemClick事件 –

+0

非常感謝你 – frnendy

回答

0

除了使用上的StackPanel螺紋事件處理程序,上使用項目單擊事件處理程序一個listView和類型投你想要的內容