Forum Xamarin.Forms

How to Reach a ContentView inside DataTemplate

JassimRahmaJassimRahma USMember ✭✭✭✭


I have below template in my app.

I would like to ask how can I reach to the SigninCointentView to get its height?

I tried simple:


but I am getting:

Error CS0103: The name 'SignupContentView' does not exist in the current context (CS0103)

    <DataTemplate x:Key="SigninViewTemplate">
        <ContentView BackgroundColor="White" x:Name="SigninContentView">
            <StackLayout Padding="15">
                <Entry x:Name="EntrySettingsSigninEmail" Margin="0,0,0,10" Placeholder="Email Address" HorizontalOptions="FillAndExpand" HorizontalTextAlignment="Center" />
                <Entry x:Name="EntrySettingsSigninPassword" Margin="0,0,0,10" IsPassword="true" Placeholder="Password" HorizontalOptions="FillAndExpand" HorizontalTextAlignment="Center" />
                <Button x:Name="btnSettingsSigninUser" Margin="0,0,0,10" Text="Sign in" Style="{StaticResource DefaultButtonStyle}" Clicked="btnSettingsSignin_Clicked" />



  • seanydaseanyda GBMember ✭✭✭✭✭

    Why would you be creating a DataTemplate to hold credential fields? What is the DataTemplate used for, a CarouselView?

    You don't want to be setting x:Name on any DataTemplate Views, You need to bind the properties to a DataTemplate. If you do want to access the Height property you need to create a Bindable Property in your Model/ViewModel and bind the value.

  • JassimRahmaJassimRahma USMember ✭✭✭✭

    it's for Syncfusion Popup..

    void btnSettingsSignup_Clicked(object sender, System.EventArgs e)
        popupLayout = new SfPopupLayout();
        popupLayout.PopupView.AppearanceMode = AppearanceMode.TwoButton;
        popupLayout.PopupView.HeightRequest = 400;
        popupLayout.PopupView.ShowFooter = false;
        popupLayout.PopupView.ContentTemplate = (DataTemplate)Resources["SignupViewTemplate"];
        popupLayout.PopupView.AnimationMode = AnimationMode.Zoom;
        popupLayout.PopupView.ShowCloseButton = true;
        popupLayout.PopupView.HeaderTitle = "Sign up";
Sign In or Register to comment.