Search code examples
c#xafxpo

C# XAF XPO Add category to listview


Im new and working with DevExpress/XAF/XPO frameworks, library added: businessobjects, and I got a question.

I want to 'simply' add a category to a listview item. In my BusinessObjects I created a tasks.cs file containing this code:

    using alot

    namespace MySolution.Module.BusinessObjects
    {

        // ... 
        [DefaultClassOptions]
    [ModelDefault("Caption", "Task")]
    public class DemoTask : Task
    {

        public DemoTask(Session session) : base(session) { }
        [Association("Contact-DemoTask")]
        public XPCollection<Contact> Contacts
        {
            get
            {
                return GetCollection<Contact>("Contacts");
            }
        }
        private Priority priority;
        public Priority Priority
        {
            get { return priority; }
            set
            {
                SetPropertyValue("Priority", ref priority, value);
            }
        }

        public override void AfterConstruction()
        {
            base.AfterConstruction();
            Priority = Priority.Normal;
        }

    }
    public enum Priority
    {
        [ImageName("State_Priority_Low")]
        Low = 0,
        [ImageName("State_Priority_Normal")]
        Normal = 1,
        [ImageName("State_Priority_High")]
        High = 2
    }
}

DemoTask is derived from Task class and in that class is the property Status of type TaskStatus which is an enum.

First: How do I get this in my listview? Second: Without displaying it in the detailview as is happening with my 'Priority' enum returning property? When I add properties they display in listview 'automatically'. Can someone point me in a direction?


Solution

  • In Order to control the views, and what is displayed in the views, You need to use the MODEL. Each project in XAF project, has a file called xxxModel.Xafml

    Double click it - navigate to Views, find the "DemoTaskListView" and then adjust the properties of the specific columns that You need. Visible = True/False