0

我创建了一个按钮并编写了它的行为来清除散点图,但它没有用:

private void Button1_Click(object sender, RoutedEventArgs e)
        {
            DependencyObject parent = VisualTreeHelper.GetParent(this);
            ScatterViewItem svi = null;
            while (parent as ScatterView == null)
            {
                if (parent is ScatterViewItem)
                    svi = parent as ScatterViewItem;
                parent = VisualTreeHelper.GetParent(parent);
            }

            ((ScatterView)parent).Items.Remove(svi);              
        }

在此之前,我想通过这段代码来重置应用程序,这也不起作用:(我添加了使用 System.Diagnostics; )

private void Button1_Click(object sender, RoutedEventArgs e)
    {    
       Process.Start(Application.ResourceAssembly.Location);    
       Application.Current.Shutdown();                      
    }

xml:

<s:SurfaceButton  Content="Clear" Name="Button1" Click="Button1_Click" VerticalAlignment="Bottom" HorizontalAlignment="Center"/>

你能告诉我我想念什么吗,谢谢

4

1 回答 1

0

你可以简单地给ScatterView一个名字

<s:ScatterView x:Name="scatterView" ... />

然后从后面的代码中访问它:

private void Button1_Click(object sender, RoutedEventArgs e)
{
    scatterView.Items.Clear();
}
于 2013-02-11T10:33:07.473 回答