How to build dynamic data entry forms in a WPF application?

后端 未结 2 885
醉酒成梦
醉酒成梦 2021-02-04 16:06

I\'m planning a WPF application which will

  • be able to create dynamic data entry forms (meaning the form gets the fields to display, their order, e
2条回答
  •  南旧
    南旧 (楼主)
    2021-02-04 17:00

    You will have to write data templates for your various field data types so that WPF will chose how to display your data depending on its type. something of this format:

    NOTE: This is not WPF just pseudo code

    
      
      
    
      
    
    

    It doesn't have to be a primitive type. It can be an Email, DateApproved or even a Url class type. e.g.

    class Customer  
    {
       public Email Email{get;set;}
       public DateTime DateApproved{get;set;}
       public URI Url{get;set;}
    }
    
    public class Email 
    {
       public string Type{get;set;}
       public string Value{get;set;} 
    } 
    

    ..etc...

    Update

    Check out this WPF Dynamic UI example on MSDN: Dynamic Data Entry with WPF and LINQ

提交回复
热议问题