- Home
- Forum
- Xamarin.Forms
- Retrieve Entry from Popup C#
Retrieve Entry from Popup C#
Hi,
I created a Popup with ContentTemplate, wich is contains DataView, inside that, a Grid.
Into the grid I had fews Entry defined x:Name="...".
In want to retrieve the entry with the name when a Button is pressed but not on the popup (On the same page but not when the popup is show). Is this possible?
SIGN IN To post a reply.
1 Reply
KK
Karthikraja Kalaimani
Syncfusion Team
April 24, 2020 02:27 PM UTC
Hi Quentien,
We cannot get the name of the entry but we can get the value of an Entry by binding a string property to the Entry and binding a command to the Button. And we can get the value of Entry on CanExecute method of the Button. For more details please refer to the below code snippet and attached sample.
Code snippet,
We cannot get the name of the entry but we can get the value of an Entry by binding a string property to the Entry and binding a command to the Button. And we can get the value of Entry on CanExecute method of the Button. For more details please refer to the below code snippet and attached sample.
Code snippet,
|
<ContentPage.BindingContext>
<local:PopupViewModel x:Name="viewModel"></local:PopupViewModel>
</ContentPage.BindingContext>
….. <sfPopup:PopupView.ContentTemplate> <DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Entry Grid.Row="0" Text="{Binding UserName}"></Entry>
<Button Grid.Row="1" x:Name="loginButton" Text="click" Command="{Binding PopupAcceptCommand}"></Button>
</Grid>
</DataTemplate>
</sfPopup:PopupView.ContentTemplate>
…. class PopupViewModel : INotifyPropertyChanged {
bool isOpen, visible;
string labelString, userName, password, showdetail;
public event PropertyChangedEventHandler PropertyChanged;
void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public ICommand PopupAcceptCommand { get; set; }
public string UserName
{
get { return userName; }
set
{
userName = value;
OnPropertyChanged(nameof(UserName));
}
}
public PopupViewModel()
{
PopupAcceptCommand = new Command(PopupAccept);
}
private void PopupAccept()
{
var a = UserName;
}
} |
Sample link : https://www.syncfusion.com/downloads/support/directtrac/general/ze/Popup_Demo824933078.zip
Regards,
Karthik Raja
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
QR Quentin Ruffier des Aimes
- Apr 23, 2020 04:55 PM UTC
- Apr 24, 2020 02:27 PM UTC