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
close icon

Custom view for Dataform Label

Hi,
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?
Thanks.

3 Replies

SP Subburaj Pandian Veluchamy Syncfusion Team 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, 
  
 
Regards,
Subburaj Pandian V   



LW Luke Woodward 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 = " *";
                layout.Children.Add(label);
                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;
        }


SP Subburaj Pandian Veluchamy Syncfusion Team 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. 
 
Regards,
Subburaj Pandian V 


Loader.
Live Chat Icon For mobile
Up arrow icon