System.NullReferenceException的Windows Phone 8.1
问题描述:
我要删除选定的堆栈面板,但是当我选择的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();
}
答
除了使用上的StackPanel螺纹事件处理程序,上使用项目单击事件处理程序一个listView和类型投你想要的内容
而你的问题是? http://*.com/help/how-to-ask – Carlo
尝试从ListBox替换为ListVIew并使用ItemClick事件 –
非常感谢你 – frnendy