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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Custom view for Dataform Label

Thread ID:





144963 May 30,2019 03:07 PM UTC Jun 3,2019 12:43 PM UTC Xamarin.Forms 3
Tags: SfDataForm
Luke Woodward
Asked On May 30, 2019 03:07 PM UTC

I am attempting to override DataFormLayoutManager.GenerateViewForLabel to replace the default label with a custom view.
This view is a StackLayout containing the result from base.GenerateViewForLabel() and another Label.
When this is returned from the overridden method, the label does not display on the form.
I have also attempted to achieve the same result by setting the FormattedText property of the Label to contain two Spans, but this also resulted in the label not displaying.
Could you please point me in the right direction for creating a header label with Custom Formatting on only a portion of the text?

Subburaj Pandian Veluchamy [Syncfusion]
Replied On May 31, 2019 01:53 PM UTC

Hi Luke, 
Thank you for contacting Syncfusion support. 
We have analyzed the reported query “DataForm Label customization with StackLayout not working”, as of now we can customize the label with custom views since DataForm is used to view Form, so the layout cannot be used as a label. Kindly share your use case to show two views for a single label. 
For wrapping the content of the label into two lines, we have already considered a feature for the same and it will be included in our upcoming Volume 2 main release. 
You can also track the status of the report by the following feedback link, 
Subburaj Pandian V   

Luke Woodward
Replied On May 31, 2019 02:04 PM UTC

  Below i have included 2 examples of the issue that I am encountering. In both cases, the label is not shown at all on the form. The reason for doing so is to mark Required fields with an asterisk where the asterisk is coloured Red, but the label text remains Black.

  protected override View GenerateViewForLabel(DataFormItem dataFormItem)
                StackLayout layout = new StackLayout() { Orientation = StackOrientation.Horizontal };
                layout.Children.Add(new Label() { Text = labelView.Text });
                var label = new Label();
                label.TextColor = Color.Red;
                label.Text = " *";
                return layout;

  protected override View GenerateViewForLabel(DataFormItem dataFormItem)
               var label = new Label()
                    FormattedText = new FormattedString()
                        Spans =
                            new Span(){Text = labelView.Text },
                            new Span(){Text = "  *", TextColor = Color.Red }
                return label;

Subburaj Pandian Veluchamy [Syncfusion]
Replied On June 3, 2019 12:43 PM UTC

Hi Luke, 
Thank you for your update. 
Query 1: Regarding passing StackLayout as custom Label view 
As we have mentioned in our previous update, Layout cannot be used as a Label view. We regret that, currently you can show only a single view for Label. 
Query 2: Regarding Spanning in the custom label using FormattedText 
As of now, we are using a fixed height for DataFormItem, so spanning does not work with a custom label. We glad to inform that we have implemented a feature to span Label content, using which you can provide multiline texts for label and Height for each DataFormItem. We will include this feature in our upcoming Volume 2 Beta release, which is expected to roll out at the mid of June 2019. We appreciate your patience until then. 
Subburaj Pandian V 


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