我想删除所选的堆栈面板,但是当我选择堆栈面板时,它会提供异常
<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 :(得分:0)
不使用Stackpanel上的Tapped事件处理程序,而是在listView上使用ItemClick事件处理程序并输入您想要的内容