RadioButton
RadioButton is a common component and describes what action will occur when you select it.
A RadioButton can only contain an icon, and can be created using style.
Create with Style
To create a radio button using style, follow these steps:
-
Create RadioButton using the default constructor:
C#CopyRadioButton utilityRadioButton = new RadioButton();
-
Apply style to RadioButton:
C#CopyButtonStyle utilityStyle = new ButtonStyle { Icon = new ImageViewStyle { Size = new Size(48, 48), ResourceUrl = new Selector<string> { Normal = "btn_radio_off.png", Selected = "btn_radio_on.png", Disabled = "btn_radio_off.png", DisabledSelected = "btn_radio_on.png", } } } utilityRadioButton.ApplyStyle(utilityStyle); utilityRadioButton.Size = new Size(48, 48); root.Add(utilityRadioButton);
Following output is generated when a radio button is created using style:
Responding to Clicked
When you click a radio button, the radio button instance receives a clicked event. You can declare the clicked event handler as follows:
C#
Copy
RadioButton button = new RadioButton();
button.Clicked += OnClicked;
C#
Copy
private void OnClicked(object sender, ClickedEventArgs e)
{
// Do something in response to RadioButton click
}
Responding to StateChangedEvent
RadioButton has the following eight states Normal
, Focused
, Disabled
, Selected
, Pressed
, DisabledFocused
, SelectedFocused
, and DisabledSelected
.
When you change the radio button state to focus or disable, the radio button instance receives a state changed event:
C#
Copy
RadioButton button = new RadioButton();
button.ControlStateChangedEvent += OnStateChange;
C#
Copy
private void OnStateChange(object sender, Control.ControlStateChangedEventArgs e)
{
// Do something in response to state change
}
Related Information
- Dependencies
- Tizen 6.0 and Higher