In C# and WPF, can you bind an element of an array to an objects property?

后端 未结 5 1900
予麋鹿
予麋鹿 2021-02-15 14:55

For example, is it possible to bind a Textblock\'s Text property to an element Name[2] of type String?

5条回答
  •  时光说笑
    2021-02-15 15:30

    Use ObservableCollection instead:

    private ObservableCollection _myItems = new ObservableCollection(new[] { "test1", "test2", "test3" });
    
    public ObservableCollection MyItems
    {
        get { return _myItems; }
        set { _myItems = value; }
    }
    

    Xaml

        
            
            
            
            
        
    

提交回复
热议问题