ObservableCollection.Contains() Doesn't Work Correctly

前端 未结 4 1332
时光说笑
时光说笑 2021-01-13 00:55

Consider the following:

class Bind
{
    public string x { get; set; }
    public string y { get; set; }
}
public partial class MainWindow : Window
{
    pub         


        
4条回答
  •  广开言路
    2021-01-13 01:44

    Because that you have added that value set to CX:

    cX.Add(new Bind { x = "a", y = "1" });
    

    and to CY:

    cY.Add(new Bind { x = "a", y = "1" });
    

    And those are different objects.

    If you want to see if a given key is present, you will need to change to a dictionary or use Linq.

提交回复
热议问题