Xaml 将CollectionViewSource筛选器与ListBox绑定

Xaml 将CollectionViewSource筛选器与ListBox绑定,xaml,binding,filter,windows-phone,collectionviewsource,Xaml,Binding,Filter,Windows Phone,Collectionviewsource,我是XAML和C的初学者# 我有下面的代码,我不知道要修改什么来解决这两个错误 Requested value 'PropertyChanged' was not found. 及 这是XAML <TextBox x:Name="textbutton1" Text="{Binding Cautare, UpdateSourceTrigger=PropertyChanged}"/> <ListBox Grid.Row="1" x:Name="ListBox" Margin="0

我是XAML和C的初学者# 我有下面的代码,我不知道要修改什么来解决这两个错误

Requested value 'PropertyChanged' was not found.

这是XAML

<TextBox x:Name="textbutton1" Text="{Binding Cautare, UpdateSourceTrigger=PropertyChanged}"/>
<ListBox Grid.Row="1" x:Name="ListBox" Margin="0,0,-12,0" ItemsSource="{Binding Sursa.View}">

以及背后的代码

public partial class MainPage : PhoneApplicationPage
    {
        public CollectionViewSource Sursa { get; set; }
        public string Cautare { get;
                set
                {
                    if (!string.IsNullOrEmpty(Cautare))
                    Filtreaza();
                    Sursa.View.Refresh(); 
                }
        }
        private void Filtreaza()
        {
            Sursa.Filter -= new FilterEventHandler(Filtru);
            Sursa.Filter += new FilterEventHandler(Filtru);
        }
        private void Filtru(object sender, FilterEventArgs e)
        {
            var src = e.Item as Rind;
            if (src == null) e.Accepted = false;
            else if (src.Text != null && !src.Text.Contains(Cautare)) e.Accepted = false;
        }
        public ObservableCollection<Rind> Lista { get; set; }

        public MainPage()
        {
            Lista = new ObservableCollection<Rind>
                        {
                            new Rind { Text = "abcd"},
                            new Rind { Text = "asdf"},
                            new Rind { Text = "asdzx"},
                            new Rind { Text = "adffgd"},
                            new Rind { Text = "asdfgea"},
                        };
            InitializeComponent();
            Sursa = new CollectionViewSource();
            Sursa.Source = Lista;
            DataContext = this;
        }
        public class Rind
        {
            public string Text { get; set; }
        }
    }
public部分类主页:PhoneApplicationPage
{
public CollectionViewSource Sursa{get;set;}
公共字符串Cautare{get;
设置
{
如果(!string.IsNullOrEmpty(Cautare))
filteraza();
Sursa.View.Refresh();
}
}
私有无效过滤区()
{
附加过滤器-=新过滤器过滤器过滤器过滤器过滤器(过滤器过滤器);
附加过滤器+=新过滤器回收器(过滤器回收器);
}
私有void filterU(对象发送方,FilterEventArgs e)
{
var src=e.作为外壳的项目;
如果(src==null)e.Accepted=false;
else如果(src.Text!=null&!src.Text.Contains(Cautare))e.Accepted=false;
}
公共ObservableCollection列表{get;set;}
公共主页()
{
Lista=新的可观测集合
{
新外壳{Text=“abcd”},
新的Rind{Text=“asdf”},
新的外壳{Text=“asdzx”},
新的Rind{Text=“adffgd”},
新的Rind{Text=“asdfgea”},
};
初始化组件();
Sursa=新集合ViewSource();
Sursa.Source=Lista;
DataContext=this;
}
公共级果皮
{
公共字符串文本{get;set;}
}
}
我已经阅读了关于CollectionViewSource和binding的其他类似问题

我的直觉告诉我这是一个常见的问题,但经过两个小时的测试,我已经进入了大脑阻塞环路,再也看不清了。所以我请求帮助。
谢谢大家!

hey@acadea首先,您已经了解了基础知识。比如属性是如何工作和定义错误的“cautar.get”必须声明一个主体,因为它没有标记为抽象、外部或部分“是因为没有定义cautar属性的get,但您正在定义它的集。 这样定义尾骨

 public string Cautare { get{ return SomeStringHere ;}
            set
            {  // you can set some value here
                if (!string.IsNullOrEmpty(Cautare))
                Filtreaza();
                Sursa.View.Refresh(); 
            }
    }
第二个错误是由于没有在代码中实现propertychanged,但您正在textbloack中使用它。这里的问题是您还必须学习数据绑定的基础知识。。
希望它能为你的问题开辟一条道路。

谢谢你的回复。事实上,我已经支持了accesor,这已经解决了,我后来发现了。但我不明白如何使用“propert changed”绑定。我成功地将“显式”作为触发器或订阅事件。它发生在每个人身上:D
 public string Cautare { get{ return SomeStringHere ;}
            set
            {  // you can set some value here
                if (!string.IsNullOrEmpty(Cautare))
                Filtreaza();
                Sursa.View.Refresh(); 
            }
    }