- Home
- Forum
- Xamarin.Forms
- [All platforms] How to use a control inside a PopupView.ContentTemplate?
[All platforms] How to use a control inside a PopupView.ContentTemplate?
Good morning,
with the following code:
<sfPopupLayout:SfPopupLayout x:Name="sfPopupLayout_NewDatabase" StaysOpen="True">
<sfPopupLayout:SfPopupLayout.PopupView>
<sfPopupLayout:PopupView ShowHeader="False" ShowFooter="False" WidthRequest="300" HeightRequest="200">
<sfPopupLayout:PopupView.ContentTemplate>
<DataTemplate>
<Grid Padding="16">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Label x:Name="label_SfPopupLayout_NewDatabase_Title" Grid.Row="0" Text="New database" FontSize="16" FontAttributes="Bold"/>
<sfTextInputLayout:SfTextInputLayout x:Name="sfTextInputLayout_SfPopupLayout_NewDatabase_DatabaseName" Grid.Row="1" ContainerType="Outlined" OutlineCornerRadius="5" FocusedColor="#007bff" ErrorColor="#dc3545" Hint="Database name">
<Entry x:Name="entry_SfPopupLayout_NewDatabase_DatabaseName"/>
</sfTextInputLayout:SfTextInputLayout>
<StackLayout Grid.Row="2" Orientation="Horizontal" HorizontalOptions="End">
<sfButtons:SfButton x:Name="sfButton_SfPopupLayout_NewDatabase_Cancel" Margin="0,10,0,0" CornerRadius="5" HeightRequest="40" BackgroundColor="#6c757d" VerticalOptions="Center" Clicked="SfButton_SfPopupLayout_NewDatabase_Cancel_Clicked" Text="Cancel"/>
<sfButtons:SfButton x:Name="sfButton_SfPopupLayout_NewDatabase_Confirm" Margin="5,10,0,0" CornerRadius="5" HeightRequest="40" BackgroundColor="#007bff" VerticalOptions="Center" Clicked="SfButton_SfPopupLayout_NewDatabase_Confirm_Clicked" Text="Confirm"/>
</StackLayout>
</Grid>
</DataTemplate>
</sfPopupLayout:PopupView.ContentTemplate>
</sfPopupLayout:PopupView>
</sfPopupLayout:SfPopupLayout.PopupView>
</sfPopupLayout:SfPopupLayout>
I would like to get and set "entry_SfPopupLayout_NewDatabase_DatabaseName" value, i would like to access to controls like inside the MainPage, how can i do that?
Thanks in advance
SIGN IN To post a reply.
2 Replies
MN
Marco Negroni
November 5, 2019 11:01 AM UTC
I need to use binding MVVM or there is another solution?
Thanks
KK
Karthikraja Kalaimani
Syncfusion Team
November 6, 2019 04:52 PM UTC
Hi Marco,
Thanks for contacting Syncfusion support.
In SfpopupLayout, we can not explicitly access the controls that are hosted inside of PopupView. In these cases, we suggested that the MVVM be used to set or get the value for that control in the code behind.
Please follow the code example,
Thanks for contacting Syncfusion support.
In SfpopupLayout, we can not explicitly access the controls that are hosted inside of PopupView. In these cases, we suggested that the MVVM be used to set or get the value for that control in the code behind.
Please follow the code example,
|
[XAML]
<ContentPage.BindingContext> <local:ViewModel x:Name="viewModel"/>
</ContentPage.BindingContext>
….
<Entry x:Name="entry_SfPopupLayout_NewDatabase_DatabaseName" Text="{Binding BookName}"/>
….. [.CS]
public MainPage()
{
InitializeComponent();
viewModel.BookName = "PopupLayout Book";
} |
Sample link : https://www.syncfusion.com/downloads/support/directtrac/general/ze/Popup_Demo-1255257019.zip
We hope this helps, please let us know If need further assistance from us.
Regards,
Regards,
Karthik Raja
SIGN IN To post a reply.
- 2 Replies
- 2 Participants
-
MN Marco Negroni
- Nov 5, 2019 10:56 AM UTC
- Nov 6, 2019 04:52 PM UTC