Adding Button Control to View
As in any Crosslight controls, you can instantiate UIRoundedButton programmatically in the runtime then add it to the view's hierarchy. In addition, the button control is also designed to support rich design-time experience through Xamarin iOS Designer. Just add the Crosslight iOS assembly to your project's reference and open the storyboard, you will see the button control in the Toolbox, under the Intersoft Crosslight category. Simply drag the control from the toolbox and drop it to the designer surface to start working with the control.
The following illustration shows the UIRoundedButton control in the Xamarin iOS Designer.
Note that Xamarin iOS Designer supports only storyboard format. For more information about working with storyboard, see Working with iOS Universal Storyboards.
Customizing Button Appearance
You can easily customize every aspect of UIRoundedButton control's appearance to your liking through the predefined styles and appearance settings. In general, the button control is automatically laid out through the combination of the following properties:
To understand how each property affects the layout and rendering of the control, please refer to the following figures.
As seen in the above figures, most of the button's appearance are customizable, from the styles, effects, colors, to fonts and margins. To find out the complete properties of the control, see UIRoundedButton class.
Handling Button Command
Enabling Toggle Mode
UIRoundedButton is not only packed with beautiful design, it is also highly functional covering numerous command scenarios. It includes support for toggle button mode, in which the selected state will remain active when tapped. You can easily enable toggle mode by simply setting the IsToggleMode property to true.
In the toggle mode, you can also set the initial state of the selection through the IsSelected binding. The following code example shows how to set the selected state of the speaker button in ViewModel.
Note that the code above presumes you have set the IsSelected binding between the SpeakerButton and the SpeakerActive property in the binding provider. The binding definition should be a two-way binding mode, allowing you to set the active state from the code, while also allow the control to set the value back when user tapped on the button. For more information about data binding in Crosslight, see Understanding Binding Providers.
Also note that you can capture the selected state in the command parameter of the delegate method, see the code example below.
Check out the comprehensive control samples here: http://git.intersoftpt.com/projects/CROS-SUPP/repos/dialogpresenter-sample/browse. Pay attention to the Call menu in the sample. Prior to running the samples, make sure to set the iOS project as the startup project.