Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 清除依赖项属性_C#_Wpf_Dependency Properties - Fatal编程技术网

C# 清除依赖项属性

C# 清除依赖项属性,c#,wpf,dependency-properties,C#,Wpf,Dependency Properties,从标准属性更新依赖属性时遇到一些问题 如果我将属性设置为null或使用新数据更新它,我的印象是它将重置依赖性属性。然而,看起来它只是把新数据堆在上面 下面是我正在使用的几个属性/依赖性属性: 依赖项属性 public static readonly DependencyProperty DataTableChartProperty = DependencyProperty.Register ("DataTableChart", typeof(DataTable), typeof(Main

从标准属性更新依赖属性时遇到一些问题

如果我将属性设置为null或使用新数据更新它,我的印象是它将重置依赖性属性。然而,看起来它只是把新数据堆在上面

下面是我正在使用的几个属性/依赖性属性:

依赖项属性

public static readonly DependencyProperty DataTableChartProperty = DependencyProperty.Register
    ("DataTableChart", typeof(DataTable), typeof(MainWindowViewModel));

public static readonly DependencyProperty ContentElementProperty = DependencyProperty.Register
    ("ContentElement", typeof(FrameworkElement), typeof(MainWindowViewModel));
public DataTable DataTableChart
{
    get { return (DataTable)this.GetValue(DataTableChartProperty); }
    set { this.SetValue(DataTableChartProperty, value); }

public FrameworkElement ContentElement
{
    get { return (FrameworkElement)this.GetValue(ContentElementProperty); }
    set { this.SetValue(ContentElementProperty, value); }
}
标准属性

public static readonly DependencyProperty DataTableChartProperty = DependencyProperty.Register
    ("DataTableChart", typeof(DataTable), typeof(MainWindowViewModel));

public static readonly DependencyProperty ContentElementProperty = DependencyProperty.Register
    ("ContentElement", typeof(FrameworkElement), typeof(MainWindowViewModel));
public DataTable DataTableChart
{
    get { return (DataTable)this.GetValue(DataTableChartProperty); }
    set { this.SetValue(DataTableChartProperty, value); }

public FrameworkElement ContentElement
{
    get { return (FrameworkElement)this.GetValue(ContentElementProperty); }
    set { this.SetValue(ContentElementProperty, value); }
}
如有任何建议,我将不胜感激。提前谢谢

这就是我现在设置的方式。。。用于测试

void _bw_DoWork(object sender, DoWorkEventArgs e)
    {
        var loadLog = new LoadLog();
        e.Result = loadLog.LoadCaseLogs(SelectedFiles);
    }

    void _bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
    {
        DataTableChart = null;
        ContentElement = null;
        ContentElement = blah;
        DataTableResult = e.Result as DataTable;
        DataTableChart = caseData.LoadUserData(DataTableResult);

        LoadingScreen = false;
    }

public ChartControl blah = new ChartControl();

使用该方法清除依赖项属性,将其设置为
null
只是将其设置为
null
,这是不同的。

使用该方法清除依赖项属性,将其设置为
null
只是将其设置为
null
,这是不一样的。

它看起来只是把新数据堆在上面,这是什么意思?请告诉我们您是如何设置属性的,因为这没有多大意义。调用
DataTableChart=null
应该就是你所需要的了。我试着把它设置为null,但我不知道它看起来像是在上面堆新数据,这是什么意思?请告诉我们您是如何设置属性的,因为这没有多大意义。调用
DataTableChart=null
应该是您所需要的。我只是尝试将其设置为null,但对meso不起作用。我会执行类似于blah.clearvalue(DataTableChart)的操作吗?@rreeves:是的,除了传递属性字段,即
DataTableChartProperty
。我会执行类似于blah.clearvalue(DataTableChart)的操作吗?@rreeves:是,除了传递属性字段,即
DataTableChartProperty