好的,所以这个问题与Windows Phone 7/Silverlight(更新的WP7工具,2010年9月)有关,特别是过滤底层ObservableCollection<T>
.
在使用WP7模板Pivot控件应用程序时,我遇到了一个问题,即更改一个底层项目ObservableCollection<T>
,不会导致屏幕上的ListBox被更新.基本上,示例应用程序有两个枢轴,第一个直接绑定到底层ObservableCollection<T>
,第二个绑定到a CollectionViewSource
(即,表示底层的过滤视图ObservableCollection<T>
).
正在添加到ObservableCollection<T>
工具的基础项INotifyPropertyChanged
,如下所示:
public class ItemViewModel : INotifyPropertyChanged
{
public string LineOne
{
get { return _lineOne; }
set
{
if (value != _lineOne)
{
_lineOne = value;
NotifyPropertyChanged("LineOne");
}
}
} private string _lineOne;
public string LineTwo
{
get { return _lineTwo; }
set
{
if (value != _lineTwo)
{
_lineTwo = value;
NotifyPropertyChanged("LineTwo");
}
}
} private string _lineTwo;
public bool IsSelected …
Run Code Online (Sandbox Code Playgroud) collections silverlight filter collectionviewsource windows-phone-7
谁能告诉我为什么这段代码的行为方式呢?查看代码中嵌入的评论......
我错过了一些非常明显的东西吗?
using System;
namespace ConsoleApplication3
{
public class Program
{
static void Main(string[] args)
{
var c = new MyChild();
c.X();
Console.ReadLine();
}
}
public class MyParent
{
public virtual void X()
{
Console.WriteLine("Executing MyParent");
}
}
delegate void MyDelegate();
public class MyChild : MyParent
{
public override void X()
{
Console.WriteLine("Executing MyChild");
MyDelegate md = base.X;
// The following two calls look like they should behave the same,
// but they behave differently!
// Why does Invoke() call …
Run Code Online (Sandbox Code Playgroud) begininvoke ×1
collections ×1
delegates ×1
filter ×1
invoke ×1
overriding ×1
silverlight ×1
virtual ×1