We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

SfCheckbox text line break

Thread ID:

Created:

Updated:

Platform:

Replies:

143131 Mar 5,2019 08:02 PM UTC May 3,2019 09:35 AM UTC Xamarin.Forms 1
loading
Tags: SfCheckBox
Minh Tran
Asked On March 5, 2019 08:02 PM UTC

Hi, at the moment my text for the checkbox is greater than the screen width. I'm wondering how do I get the text to wrap/line break when the width is large.  

Bharathiraja K [Syncfusion]
Replied On May 3, 2019 09:35 AM UTC

Hi Minh Tran, 
 
Thanks for contacting Syncfusion support. 
 
Query: How do I get the text to wrap/line break when the width is large.  
 
SfCheckBox's text has been wrapped automatically in Android and UWP platforms. For iOS, we have achieved your requirement using SizeThatFits override method in custom renderer (CheckBox_IndeterminateState.iOS/ CheckBoxRenderer) of SfCheckBox control.  Please download the sample in below link  
 
 
Code Example [C#]: 
 public override CGSize SizeThatFits(CGSize size)
        {
            var sizeValue = base.SizeThatFits(size);
            var text = Control.TitleLabel.Text;
            if (!string.IsNullOrEmpty(text))
            {
                NSString nsstring = new NSString(text);
                UIStringAttributes attribs = new UIStringAttributes
                {
                    Font = Control.Font,
                    ParagraphStyle = new NSMutableParagraphStyle()
                    {
                        LineBreakMode = UILineBreakMode.CharacterWrap
                    }
                };

                CoreGraphics.CGRect textSize = nsstring.GetBoundingRect(new CGSize(width, double.MaxValue), NSStringDrawingOptions.UsesLineFragmentOrigin, attribs, null);
                float strikeHeight = (float)textSize.Height;

                return new CGSize(sizeValue.Width, strikeHeight);
            }

            return sizeValue;
        }
 
 
Please let us know, if you have any other queries. 
 
Regards, 
Bharathi. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon