C# 过滤器不是';t更新Itemsource查询

C# 过滤器不是';t更新Itemsource查询,c#,xaml,C#,Xaml,这是一个相当基本的问题,但我想知道为什么它没有更新或是动态的。基本上,当选择不同的日期时,查询应该更改 private DateTime StartDateTo; public DateTime _StartDateTo { get { return _StartDateTo; } set { _StartDateTo = value; Filter(); } } private DateTime EndDateTo; public DateTime _EndDateTo { get {

这是一个相当基本的问题,但我想知道为什么它没有更新或是动态的。基本上,当选择不同的日期时,查询应该更改

private DateTime StartDateTo;
public DateTime _StartDateTo { get { return _StartDateTo; } set { _StartDateTo = value;     Filter(); } }
private DateTime EndDateTo;
public DateTime _EndDateTo { get { return _EndDateTo; } set { _EndDateTo = value; Filter(); } }
private ObservableCollection<Quarterly> _QuarterlyInfo;
public ObservableCollection<Quarterly> QuarterlyInfo { get { return _QuarterlyInfo; } set{_QuarterlyInfo = value; Filter();} }


public ReportGridViewModel(IEventAggregator events)
{            
    EndDateTo = new DateTime(2013, 4, 1);
    StartDateTo = new DateTime(2010, 6, 30);
    QuarterlyInfo = new ObservableCollection<Quarterly>();
    Generalinfo = new Quarterly();          
    Filter();
}

public new void Filter()
{
    using (FBContext ctx = DB.Get())
    {
        QuarterlyInfo.Clear();
        //*************************** General Inquiry ******************************//
        Generalinfo = new Quarterly();
        var general = from z in ctx.Interactions
                      where z.ActivityDate >= StartDateTo && z.ActivityDate <= EndDateTo && z.Indepth == false
                      select new { Indepth = z.Indepth };
        Generalinfo.SectionInfo = "# of General Inquiries";
        Generalinfo.Result = general.Count();
        QuarterlyInfo.Add(Generalinfo);
    }
}

像这样的方法应该会奏效:

    private DateTime _StartDateTo;
    public DateTime StartDateTo 
    { 
        get { return _StartDateTo; } 
        set 
        { 
            _StartDateTo = value;
            Filter();
            NotifyOfPropertyChange(() => StartDateTo);
        } 
    }
    private DateTime _EndDateTo;
    public DateTime EndDateTo
    { 
        get { return _EndDateTo; }
        set
        {
            _EndDateTo = value;
            Filter();
            NotifyOfPropertyChange(() => EndDateTo);
        }
    }
    private ObservableCollection<Quarterly> _QuarterlyInfo;
    public ObservableCollection<Quarterly> QuarterlyInfo
    {
        get { return _QuarterlyInfo; } 
        set 
        {
            _QuarterlyInfo = value;
            Filter();
            NotifyOfPropertyChange(() => QuarterlyInfo);
        }
    }
private DateTime\u StartDateTo;
公共日期时间开始日期
{ 
获取{return\u StartDateTo;}
设置
{ 
_StartDateTo=值;
过滤器();
财产变更通知(()=>StartDateTo);
} 
}
私有日期时间_EndDateTo;
公共日期时间EndDateTo
{ 
获取{return\u EndDateTo;}
设置
{
_EndDateTo=值;
过滤器();
NotifyOfPropertyChange(()=>EndDateTo);
}
}
私人可观察收集信息;
公共可观测收集季度信息
{
获取{return\u quartlyinfo;}
设置
{
_QuarterlyInfo=值;
过滤器();
财产变更通知(()=>QuarterlyInfo);
}
}

您的类似乎没有实现INotifyPropertyChanged。此链接可能会帮助您:我正在使用caliburns PropertyChangedBase,它相当于InotifyPropertyChanged。在绑定的属性的设置程序中,请尝试调用
NotifyOfPropertyChange(()=>YourPropertyName)Filter()后,code>(我相信这就是Caliburn使用的)
然后看看这是否对你有效。我绝对认为这是正确的方法。我刚刚在
quartlyinfo.Clear()处得到一个错误空引用添加了第三种情况,可以继续吗??新的可观察集合()`好交易。我很高兴能帮上忙。
    private DateTime _StartDateTo;
    public DateTime StartDateTo 
    { 
        get { return _StartDateTo; } 
        set 
        { 
            _StartDateTo = value;
            Filter();
            NotifyOfPropertyChange(() => StartDateTo);
        } 
    }
    private DateTime _EndDateTo;
    public DateTime EndDateTo
    { 
        get { return _EndDateTo; }
        set
        {
            _EndDateTo = value;
            Filter();
            NotifyOfPropertyChange(() => EndDateTo);
        }
    }
    private ObservableCollection<Quarterly> _QuarterlyInfo;
    public ObservableCollection<Quarterly> QuarterlyInfo
    {
        get { return _QuarterlyInfo; } 
        set 
        {
            _QuarterlyInfo = value;
            Filter();
            NotifyOfPropertyChange(() => QuarterlyInfo);
        }
    }