Current filter:
                                You should refresh the page.
                                  • Description:
                                    Hi,
                                    I want to know how to remove the "Choose Skin" button and New/Link/Unlink buttons from my view:


                                    Answer:
                                    1. Actions in XAF UI are represented via the buttons, drop-down lists, text boxes, etc. Please check the Actions help topic for more information.
                                    2. Almost every Action is provided by a Controller.
                                    3. To deactivate any Action from View (i.e. to make it invisible or remove from the screen), you need to call the SetItemValue method of its Active  property, passing False as the second parameter.
                                    To disable any Action from View (i.e. to make it visible, but inaccessible, grayed out), you need to call the SetItemValue method of its Enabled property, passing False as the second parameter.
                                    4. To access a Controller, you can use the GetController method or the Controllers property provided by the Frame class (note the Window class descends from Frame).
                                    To access an Action, use the Actions property of the Controller class (YourController.Actions["YourActionId"] ) or use predefined properties of built-in Controllers (e.g., NewObjectViewController.NewObjectAction).
                                    5.  The code that manages availability of Controllers and Actions usually resides within your custom Controllers (e.g., within the overridden OnActivated method of a ViewController or WindowController), which are placed inside of modules. Refer to the Implement Custom Controllers and Deactivate an Action articles to learn more on this.
                                    Your goal is only to find the corresponding Controller and access the required Action using the API described in #4.

                                    In order to find this, check this help topic: Built-in Controllers and Actions. In addition, you might want to check the XAF sources that ship with our framework to find the name of a Controller that owns a particular Action. For instance, take a look at the following folders:
                                            *%ProgramFiles%\DevExpress\DXperience 1X.X\Sources\DevExpress.ExpressApp\DevExpress.ExpressApp\SystemModule*
                                            *%ProgramFiles%\DevExpress\DXperience 1X.X\Sources\DevExpress.ExpressApp\DevExpress.ExpressApp.Win\SystemModule*
                                            *%ProgramFiles%\DevExpress\DXperience 1X.X\Sources\DevExpress.ExpressApp\DevExpress.ExpressApp.Web\SystemModule*
                                            *%ProgramFiles%\DevExpress\DXperience 1X.X\Sources\DevExpress.ExpressApp.Modules*
                                    Finally, it is possible to invoke the Model Editor tool and navigate to the ActionsDesign | Actions node and identify a required Action by its Id or Caption properties. Then, its Controller property will point to the required controller you need to customize:

                                    Take special note that Actions defined via the ActionAttribute are generated at runtime by the ObjectMethodActionsViewController class. The Id of such a runtime Action is formed using the following pattern:
                                    <short name of a container class> + <name of the method marked with ActionAttribute>
                                    For instance, at runtime, you can use the following code:

                                    [C#]
                                    DevExpress.ExpressApp.SystemModule.ObjectMethodActionsViewController controller = Frame.GetController<DevExpress.ExpressApp.SystemModule.ObjectMethodActionsViewController>(); if(controller != null) { controller.Actions["Task.MarkCompleted"]; }

                                    6. More examples follow below:

                                    [C#]
                                    namespace MainDemo.Module.Win{ public partial class ViewController1 : ViewController { public ViewController1() { InitializeComponent(); RegisterActions(components); } protected override void OnActivated() { base.OnActivated(); if (View is ListView && !View.IsRoot && View.ObjectTypeInfo.Type == typeof(DemoTask)) { DevExpress.ExpressApp.SystemModule.LinkUnlinkController linkUnlinkController = Frame.GetController<DevExpress.ExpressApp.SystemModule.LinkUnlinkController>(); if(linkUnlinkController != null) { linkUnlinkController.LinkAction.Active.SetItemValue("myReason", false); } } } } } namespace WinSolution.Module.Win { public partial class WindowController1 : WindowController { public WindowController1() { InitializeComponent(); RegisterActions(components); } protected override void OnActivated() { base.OnActivated(); DevExpress.ExpressApp.Win.SystemModule.ChooseSkinController chooseSkinController = Window.GetController<DevExpress.ExpressApp.Win.SystemModule.ChooseSkinController>(); if(chooseSkinController != null) { chooseSkinController.ChooseSkinAction.Active.SetItemValue("myReason", false); } } } } namespace MainDemo.Module.Win { public partial class ViewController1 : ViewController { public ViewController1() { InitializeComponent(); RegisterActions(components); } protected override void OnActivated() { base.OnActivated(); if (View.Id == "Contact_LookupListView") { DevExpress.ExpressApp.Win.SystemModule.WinNewObjectViewController winNewObjectViewController = Frame.GetController<DevExpress.ExpressApp.Win.SystemModule.WinNewObjectViewController>(); if(winNewObjectViewController != null) { winNewObjectViewController.NewObjectAction.Active.SetItemValue("myReason", false); } } } } }

                                    7. Check out the Managing availability of Controllers and Actions section of the Best practices of creating reusable XAF modules by example of a View Variants module extension blog post for more detailed information.
                                    8. If you need to know why a certain Action/Controller is deactivated or disabled, use the DiagnosticInfo Action.
                                    See Also:
                                    Built-in Controllers and Actions
                                    Add a Simple Action
                                    Deactivate an Action
                                    How to: Remove the New Button

                                • Gilson Appel 06.10.2014

                                  What if I want to hide the item but still execute de action?
                                  Is there a way to fully hide it but allow it to be executed in my controller?
                                  OR
                                  Is there a way to create a action and invoke it just by code?

                                • Dennis (DevExpress) 06.10.2014

                                  @Gilson:
                                  Sure, that is possible. For instance, an Action will be invisible in the UI if it is not mapped to any existing Action Container in the form template.
                                  So, you can set the Category property of your Action to an arbitrary string, which is not equal to the standard categories, e.g.: yourAction.Category = "I do not want it to be visible in the UI";

                                • Mysoft Systems 11.30.2014

                                  Is there a way to hide buttons through the model editor? For example, if I have a multi purpose screen which 4 employees will use. Each employee has a different function on the screen. I would like to customize the controllers/actions available to each employee through the model editor, in this way the form has all actions available, though I can decide at runtime which actions each employee can use... (we are saving the Model for each user so each one will show their personal screen). Please let me know if this is a possibility - that would be great.

                                • Dennis (DevExpress) 12.01.2014

                                  You can customize the Views | View | HiddenActions node and specify certain Actions you want to be hidden in each View. I hope this solution meets your needs.

                                0 Solutions

                                Creation Date Importance Sort by