I have been trying out Uno recently. It's a great development tool for cross-platform applications. One thing that new converts have always questioned, is the lack of a forms designer. Having written Xamarin Controls to help with this in Xamarin, I decided to do the same for Uno.
We haven't come up with a forms designer, but we have come up with a way of generating the XAML to create controls in your code.
We are hoping that this is helpful for existing Uno developers, but will also help those new to the platform easily generate controls, which they can then tune to their own requirements.
Released as an add-in to Visual Studio, Uno Controls Helper will allow you to choose from a pre-set of properties for a control, and will generate the XAML and insert it into your XAML code.
The Uno Controls add-in operates in the same way as the Xamarin Controls add-in.
You can see a video of the Uno Controls add-in in action here.
Currently we cater for adding the code for the following controls:-
- Date/Time Picker
- Radio Buttons
- Check Box
Simply right-click in your XAML code window to get a menu of controls.
Select the control you want to generate and a 'selection box' appears, allowing you to choose properties for your control. In this case we have chosen 'TextBlock'.
If you are using a 'style' for your TextBlock, you can enter it in the 'style' box, and if you have a binding context, again, enter it into the box, and it will replace the 'text' entry in the code.
All the 'parameters' are in drop-down lists, so you shouldn't be able to generate invalid code. Properties that can be entered, such as Padding or Margin are validated before code generation. We don't do any validation on Style or Binding Context.
The parameters persist between sessions, but if you right click on the 'group box' containing all the controls, you can go back to the default parameters.
If you select 'Control in Grid', 3 more fields appear, allowing you to select a row, column and column span, to place your control in a grid. This is available in all the controls, except the grid control.
If we change the name above to lblWelcome, and leave all the other parameters as they are, click on OK, the following code is inserted your XAML:-
Which generates this on your form:-
Some of the controls have a 'Create Event?' property. If you set this to 'true' then the generated code will have an event generated for you. The code below for the button has generated the 'click' event code. You will still need to write the code behind though. As you see below, we have generated the Click event using the name of the control and _OnClick.
The screenshot below shows a sample 'Log In' screen showing some of the controls - this is completely generated code from the Uno controls add-in. This code took less than 5 minutes to generate.
Please let us know if you have any suggestions for additional controls, or the existing controls.