Can static data for Datagrid rows be defined purely in XAML i.e. no code behind?

后端 未结 3 1265
伪装坚强ぢ
伪装坚强ぢ 2020-12-31 04:41

I have static data that I want to display in Datagrid format. The values are for display purposes only and will not change. Can it be added as some kind of subtag of the Dat

3条回答
  •  一生所求
    2020-12-31 04:56

    You can do static data in XAML, yes, but you will need to create a simple class for the record format. For example, you could create this class file:

    namespace TestNamespace
    {
        public class MockRecord
        {
            public string FirstName { get; set; }
            public string LastName { get; set; }
            public string Email { get; set; }
        }
    }
    

    Now in your XAML DataGrid you can do this:

    
    
        
            
            
            
        
    
         
         
         
         
    
    

提交回复
热议问题