Hello, I have XAF application and some custom form.
How can I get access to the XafApplication instance in my custom form through a constructor??? Please help me with code.
Get access to the XafApplication
Answers
Hello Mihail,
Thank you for contacting us. Please review the How to show custom forms and controls in XAF (Example) example. It shows how to pass the XafApplication instance in a scenario when a custom form is invoked from a Controller.
In ASP.NET, you can use the static WebApplication.Instance property. There is no such property in WinForms, I am afraid. But you can implement your own static class (e.g., ApplicationHelper) and initialize its XafApplication property after you create your XafApplication in the Main routine.
I hope this helps.
@Willem: I hid the deprecate blog link, but the first link from my original answer is still valid. Also, in the latest XAF version, there were improvements that simplify accessing the XafApplication and IObjectSpace entities from within custom controls: How to: Show a Custom Data-Bound Control in an XAF View (WinForms). Please take another moment to review these learning materials and let me know if you require further assistance after this. If so, create a separate Support Center ticket, and describe your use-case scenario and current implementation difficulties with it and XAF.