Completed
Last Updated: 30 May 2017 10:30 by ADMIN
ADMIN
Julian Benkov
Created on: 23 Apr 2010 03:55
Category: Buttons
Type: Bug Report
2
FIX. RadToggleButton - simple data binding is not working when binding to a nullable boolean
Parse event of the property binding is not fired when you change the ToggleState value of RadToggleButton:

Workaround:

private void Form1_Shown(object sender, EventArgs e)
		{
            Binding b = new Binding("ToggleState", vm, "IsToggleSet", true, DataSourceUpdateMode.OnPropertyChanged);
			b.Format += new ConvertEventHandler(b_Format);
			b.Parse += new ConvertEventHandler(b_Parse);
			radToggleButton1.DataBindings.Add(b);
		}

		void b_Parse(object sender, ConvertEventArgs e)
		{
			if (e.DesiredType != typeof(bool) || !(e.Value is ToggleState))
				return;

			ToggleState state = (ToggleState)e.Value;
			e.Value = (state == ToggleState.On) ? true : false;
		}

		void b_Format(object sender, ConvertEventArgs e)
		{
			if (e.DesiredType != typeof(ToggleState) || !(e.Value is bool))
				return;

			bool isToggleOn = (bool)e.Value;
			e.Value = isToggleOn ? ToggleState.On : ToggleState.Off;
		}
1 comment
ADMIN
Ralitsa
Posted on: 30 May 2017 10:30
Due to the specifics of the simple data binding, we have introduced the CheckChanging / CheckChanged events together with the CheckState property. These events and property provide the same functionality as the ToggleStateChanged, ToggleStateChanging and the ToggleState property, but give you the ability to simple data bind the control. The feature is available since Telerik UI for WinForms Q1 2014 version.