Forum Xamarin.Forms

Control Templating issue on UWP

galactosegalactose Member ✭✭

Hi all,

I face an issue using a ControlTemplate in UWP. It works very well on Android, not tested on iOS:

Here my XAML

<MyPage>
    <!-- All fits in a ScrollView and a StackLayout -->
    <!-- Some basic controls here like Label, Entry -->

    <ui:DescriptionFrame>
        <StackLayout>
            <Label Style="{StaticResource DescriptionFrameTitle}"
                    Text="{Binding Resources[Advert], Converter={StaticResource StringCaseConverter}, ConverterParameter=U}" />
            <BoxView Style="{StaticResource DescriptionFrameBoxView}" />
            <ui:LabelJustify FontSize="14"
                                FormattedText="{Binding ScoreResources[PhhfGroup_Advert], Converter={StaticResource MarkdownConverter}}" />
            <ui:SourceLabel Title="{Binding Resources[Source]}"
                            SourceName="{Binding ScoreResources[PhhfGroup_Source]}"
                            SourceUrl="{Binding ScoreResources[PhhfGroup_URL]}" />
        </StackLayout>
    </ui:DescriptionFrame>

    <!-- End of StackLayout and ScrollView -->
</MyPage>

And here my DescriptionFrame

using Xamarin.Forms;

namespace CardioCALC.UI.Mobile
{
    public class DescriptionFrame : Frame
    {
        private readonly ControlTemplate DescriptionFrameTemplate = new ControlTemplate(type: typeof(DescriptionFrameTemplate));

        public DescriptionFrame()
        {
            ControlTemplate = DescriptionFrameTemplate;
        }
    }

    public class DescriptionFrameTemplate : StackLayout
    {
        public DescriptionFrameTemplate()
        {
            Children.Add(new ContentPresenter());
        }
    }
}

As it was a bit complicated, I pasted here only the code needed for this bad behavior. Also, I tried to keep all my BindableProperty objects in the DescriptionFrame class and add them in the DescripitonFrameTemplate.Children, without ContentPresenter() ==> ContentPresenter() is not the problem.

So, what I obtain on UWP is a BLANK page !!! Nothing is displayed, even controls that are declared BEFORE the DescriptionFrame... Navigation works so I can go backward. I tried to just have a Label, then the DescriptionFrame, in a single StackLayout, in a simple ContentPage and assign this ContentPage to the App.MainPage property: the Label is not showing...

How to deal with this ?

Thanks,
Galactose

Best Answer

Answers

  • galactosegalactose Member ✭✭
    Thanks a lot, I googled it but I did not find this issue reporting, I may have looked poorly ! I suscribed to it.
Sign In or Register to comment.