Xamarin.Forms does not have the capability to export UI elements as an image, thus Telerik UI for Xamarin does not have it either.
However, you can write a custom Xamarin.Forms DependencyService to leverage the native platform's features and render that native screen to a png or jpg using the native platform APIs.
I have an open source demo project that shows you how to do this:
- Go to my Custom Xamarin Demos repository.
- Go into the Render Image demo's folder.
- Read the README very carefully to understand how to use the DependencyService (specifically the Methods section, you can ignore the PDF section).
You may be asking yourself how to pass in a specific UI control, but you'll see that there is no easy way to do that because the native platform doesn't know what a Xamarin.Forms control is.
So, the DependencyService methods has works by rendering the screen, then cropping out the section of the screen you want. Here's the overload of the method:
The Render method returns a
byte of a png or jpeg encoded image and has overloads to set a cropping region.
RenderAsync(RenderEncodingOptions encodingFormat): Returns a capture of entire screen.
RenderAsync(int X, int Y, int Width, int Height, RenderEncodingOptions encodingFormat): Returns a capture of a cropped region using absolute position values
RenderRelativeAsync(int X, int Y, int Width, int Height, RenderEncodingOptions encodingFormat): Renders a capture of a cropped region using proportional position values
Options 2 and 3 give you the ability to crop any section of the screen so that you can get capture of specific content (e.g. Charts, Graphs, Scoreboards, etc). All methods have a default encoding of
RenderEncodingOptions.Png, but you can choose
RenderEncodingOptions.Jpeg when needed (i.e. inserting into a PDF).
Using the Image
Once you get the png/jpg encoded byte back from the DependencyService, you can whatever you want with it (e.g. embed it in an HTML report).
> Please be aware that the example is not an official Telerik demo and we do not provide support for it. I get the question of exporting frequently enough that I wanted to build a demo to give developers a head start.
Regarding the 2nd question on projection, I see you have already found the feature request to support other projections. At this time, the Feature Request is set to Unplanned.
This means it has been approved as a viable feature, but is not currently planned for a specific release (i.e. it hasn't started development, the team will monitor demand for the Feature Request and adjust its priority accordingly).
You can convert some projections coordinates with 3rd party libraries and there are dozens of articles and topics on the matter online.
For example, you could also use a library like ProjNET (highly recommended, the ProjNET4GeoAPI NuGet package port written by a Microsoft MVP). I recently used ProjNET to do a conversion from UTM coordinates, here's what that looks like:
If you have any specific trouble with the RadMap, please open a Support Ticket and share the problematic code. The team will be able to give you specific help for your code, privately.
We do our best to answer forum threads in a timely fashion, but it can take up to several days depending on current support load (i.e. 24hr Support Tickets always take priority over forum posts).
Lance | Manager - Technical Support