by Joche Ojeda | Feb 18, 2019 | Web, XAF
Sometimes we need to have clientside events and handle them on the server side code behind, that in a simple asp.net web page is really easy, you just have to execute a javascript that executes an HTTP request to the server. Now the question is, how do we do that in XAF?
Well, the concept is basically the same but you need to know XAF architecture the problem is that most of the code needed is not documented, but after a while, I manage to figure it out, so let’s get started.
1) Create a XAF web application
2) On your web module add a view controller
3) Implement the interface IXafCallbackHandler on the controller you just added in step 2, this is the method that will be called as a callback from javascript. This interface is not documented on the DevExpress website
4) In your view controller add a property to access XafCallbackManager
5) Override the OnViewControlsCreated method and register your callback, in this example, the name of the callback is “MyScript”
6) Now add a simple action and wire the execute event, on the execute event cast the frame as a web window and register a startup script. The code surrounded with the blue line is the javascript that triggers the callback in the callback manager, the code surrounded with red is the id if the script that we are listening for, it should match the name of the script registered on the handler in the previous step.
To execute the callback somewhere in your javascript you have to execute the following function RaiseXafCallback, this function is not documented on the DevExpress website
RaiseXafCallback(globalCallbackControl, 'TheIdOfYourHandler', 'AnyStringThatRepresentsTheValuesYouWantToPassToTheCallBack', '', false);
7) Run your application and execute the simple action added in step 6, when the javascript finish executing, the method you implemented on step 3 will be executed.
The code for this article is here the full example is in GitHub
by Joche Ojeda | Jan 26, 2019 | Forms, UAP/UWP, Xamarin
For a long time now, I have wanted to access the file system when I create a Xamarin Forms UAP/UWP application but that was actually impossible … till now. After the Windows 10 build 17134 update its possible to access the broad file system, the approach is not straight forward.
To gain access to the file system in your Xamarin Forms UAP/UWP application follow these steps
1) Go the properties of your UAP/UWP application and check the targeting, the minimum should be at least 16299, what I recommend is 171344
You can also change the targets unloading the project and editing the csproj file
2) In your solution explorer edit your Package.appxmanifest by selecting it and press F7, looking the file from the top should look like the image below
Add this namespace xmlns:rescap=”http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities and update the IgnorableNamesSpaces like this IgnorableNamespaces=”uap mp rescap” after the changes your file should look like the image below
3) Lookup for the capabilities node in the manifest and add a new capability <rescap:Capability Name=”broadFileSystemAccess” /> your capabilities section should look like the image below
4) Rebuild your application, then select it on the solution explorer, right click over it and click on deploy, this will register the application in your OS
5) on your Windows OS go to settings>File system privacy settings and you will see all the UAP/UWP applications that are registered in your OS and have access to the file system, here you can allow/deny the access to the file system in general or by application
6) now everything is ready for your app to access the file system, but there is a little catch, in most cases, you cannot use the classes in system.io to access the file system you have to use Windows.Storage.Storagefolder below is a code snippet that illustrates how to use such class
public async void GetDirectories(string sDir)
{
var folder = await StorageFolder.GetFolderFromPathAsync(sDir);
foreach (var file in await folder.GetFilesAsync())
{
Debug.WriteLine(file.Name);
}
}
I have created a sample app using these steps, you can download the source from GitHub
by Joche Ojeda | Jan 11, 2019 | Code Rush, Custom Templates, Entity Framework Core
Don’t waste your time writing boilerplate code, just use Code Rush from DevExpress
Entity Framework Class (shortcut efc)
Entity Framework Property (shortcut efpr)
Entity Framework Property (shortcut efnp)
Entity Framework Collection (shortcut efcol)
Entity Framework extensions (shortcut efext)
Entity Framework ModelBuilder Association (shortcut efrom)
You can download all these amazing code templates here [download id=”241″]
by Joche Ojeda | Dec 8, 2018 | Application Framework, Brevitas Application Framework
Let’s try to define what is an application framework, for that we will check how famous website defines the term “Application Framework”
In computer programming, an application framework[1] consists of a software framework used by software developers to implement the standard structure of application software.[2]
From techopedia
An application framework is a software library that provides a fundamental structure to support the development of applications for a specific environment. An application framework acts as the skeletal support to build an application.
Now my own definition of an application framework
An application framework is a set of tools, components and design patterns that allow the programmer to develop an application for a well define pourpose (like a business application, a game etc..). The main pourpse of an application framework should be reduce the development time and allow the developer to focus on the main pourpouse of the application instead of the application infrastructure
That is all for now, as you can see the concept is really simple but as they say “devil lies on the details”. In the upcoming post, we will define the parts of an application framework.
by Joche Ojeda | Dec 2, 2018 | Code Rush, Custom Templates, DevExpress, Xamarin, Xamarin Forms
From time to time I realize that a lot of the stuff I’m writing is repetitive and complex, so that is the perfect time to create a new code rush custom template, behold the new template xfbp (xamarin forms bindable property). Download the template here [download id=”211″]
Do you want to see it in action?