Ticket Q204692
Visible to All Users

Use LookupControlTemplate for specific domain object

created 16 years ago

Hello,
I've made a custom LookupControlTemplate in which I can use advanced filtering for the listview. Now, I only want to use this template when looking up a specific domain object, in this case the Article item. Currently, I'm using the application.CreateCustomTemplate event to show the new template, but I can't seem to use it for the Article object only. Can anyone help me?
Thanks in advance
Xavier

Show previous comments (4)

    Solved.

      Hello Dennis,
      Sorry for bothering u with this problem again. I thought I had it figured out, but apparently, it didn't work out at all. I've been trying to find out how to do it, but with no result. Would u mind taking a closer look at it please? I've included a testproject and a screenshot of what I want to achieve.
      Thanks in advance
      Xavier

      Dennis Garavsky (DevExpress) 16 years ago

        Hello Xavier,
        Thanks for the sample. We are working on it and will answer ASAP.
        Thanks,
        Dennis

        Answers

        created 16 years ago (modified 5 years ago)

        Hello Xavier,
        Thanks for your patience. I have attached a modified version of your sample showing how to solve your problem. Please let me know in case of any difficulty.

        Let me also elaborate on the ideas behind this solution:

        1. Create a new show view strategy class, derived from the existing strategy (for instance from the ShowInMultipleWindowsStrategy) and with a System.Type property (DetailViewObjectType):
        C#
        public class MyShowInMultipleWindowsStrategy : ShowInMultipleWindowsStrategy { public MyShowInMultipleWindowsStrategy(XafApplication application) : base(application) { } private Type \_detailViewObjectType; public Type DetailViewObjectType { get { return \_detailViewObjectType; } } protected override void ShowViewCore(ShowViewParameters parameters, ShowViewSource showViewSource) { \_detailViewObjectType = null; if (parameters.CreatedView is DetailView) { if (parameters.CreatedView.ObjectType == typeof(DomainObject1) || parameters.CreatedView.ObjectType == typeof(DomainObject2) || parameters.CreatedView.ObjectType == typeof(DomainObject3)) { \_detailViewObjectType = parameters.CreatedView.ObjectType; } } base.ShowViewCore(parameters, showViewSource); } }
        1. Override the ShowViewCore method to obtain the information about the currently opened view to determine its object type.
          It will be accessed via the DetailViewObjectType property.
        2. Declare a custom application class, derived from the WinApplication class, and override the CreateShowViewStrategy virtual method to create the required strategy:
        C#
        public class MyWinApplication : WinApplication { protected override ShowViewStrategyBase CreateShowViewStrategy() { return new MyShowInMultipleWindowsStrategy(this); } }
        1. Create a custom template for the required object type as described in Template Customization.
        C#
        static void Main() { //... MyWinApplication winApplication = new MyWinApplication(); winApplication.CreateCustomTemplate += new EventHandler<CreateCustomTemplateEventArgs\>(winApplication\_CreateCustomTemplate); //... } static void winApplication\_CreateCustomTemplate(object sender, CreateCustomTemplateEventArgs e) { if (e.Context.Name == TemplateContext.View) { Type objectType = ((MyShowInMultipleWindowsStrategy)(((MyWinApplication)sender).ShowViewStrategy)).DetailViewObjectType; if (objectType == null) { e.Template = new DevExpress.ExpressApp.Win.CustomTemplates.DetailViewForm(); return;| } if (objectType == typeof(DomainObject1)) e.Template = new DevExpress.ExpressApp.Win.CustomTemplates.DetailViewForm1(); else if (objectType == typeof(DomainObject2)) e.Template = new DevExpress.ExpressApp.Win.CustomTemplates.DetailViewForm2(); else if (objectType == typeof(DomainObject3)) e.Template = new DevExpress.ExpressApp.Win.CustomTemplates.DetailViewForm3(); } } }

        Thanks,
        Dennis

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.