Bind to Count of items in the DataContext

后端 未结 5 1234
别跟我提以往
别跟我提以往 2021-02-12 03:45

I want to bind to the Count/amount of items within my DataContext.

I have an object, lets say person which has a List

as a property. I would
5条回答
  •  感动是毒
    2021-02-12 03:57

    XAML:

    
        
            
        
    
    

    Code behind:

    using System.Collections.Generic;
    using System.Windows;
    
    namespace CountDemo
    {
        public partial class Window1 : Window
        {
            public Window1()
            {
                InitializeComponent();
    
                DataContext = new Person();
            }
        }
    
        public class Person
        {
            public List
    Addresses { get { return new List
    () {new Address(), new Address(), new Address()}; } } } public class Address { } }

提交回复
热议问题