xamarin/Xamarin.Forms

Margin, Height request and Width request is not applied for Label while converting the forms view to native view in Xamarin.Forms

Ouverte

#3 537 ouverte le 10 août 2018

 (3 commentaires) (0 réaction) (0 personne assignée)C# (1 926 forks)batch import
e/4 :clock4:help wantedinactivet/bug :bug:up-for-grabs

Métriques du dépôt

Stars
 (5 644 étoiles)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

Description

Hi Team,

We are tried to convert the forms view to native view. But in this approach, given margin is not applied for the Label. We are loading Label inside a DataTemplate which is the property in Customview derived from Content view. Please refer the attached issue reproducing sample.

Custom View: public class CustomView:ContentView {
public CustomView() {
} public static readonly BindableProperty ContentTemplateProperty = BindableProperty.Create("ContentTemplate", typeof(DataTemplate), typeof(CustomView), null, BindingMode.TwoWay); public DataTemplate ContentTemplate { get { return (DataTemplate)GetValue(ContentTemplateProperty); } set { SetValue(ContentTemplateProperty, value); } } }

Native view Conversion in Forms.UWP: internal static FrameworkElement ConvertFormsToNativeView(Xamarin.Forms.View view, CustomView formscustomView, int width, int height) { FrameworkElement native = null; var templateLayout = view as Xamarin.Forms.View; var renderer = ConvertToNative(templateLayout, formscustomView); native = renderer as FrameworkElement; templateLayout.Measure(width, height); templateLayout.Layout(new Xamarin.Forms.Rectangle(0, 0, width, height)); return native; }

Similarly we are converting in Xamarin.Forms.Android and Xamarin.Forms.iOS.

Mainpage.xaml: <ContentPage.Content> <local:CustomView x:Name="customView" HeightRequest="300" WidthRequest="300" IsVisible="True"> local:CustomView.ContentTemplate </local:CustomView.ContentTemplate> </local:CustomView> </ContentPage.Content>

Steps to Reproduce

  1. Run the attached sample.
  2. Note that given margin for label is not applied.
  3. Click the button to collapse the visibility of custom view.

Expected Behavior

Given margin must be applied to the label.

Actual Behavior

Given margin is not applied to the label.

Basic Information

  • Version with issue: 2.4.0.280
  • Platform Target Frameworks:
    • iOS: 11.2, 11.4,11.9
    • Android: 23, 24
    • UWP: 14393
  • Nuget Packages:2.4.0.280
  • Affected Devices: all the devices

Reproduction Sample Link

FrameWorkListView.zip

Guide contributeur