Attempting to utilize Xamarin Community Toolkit Popups in Xamarin Forms MVVM pattern project, target platforms IOS & Android. Popups are appearing, however I cannot bind to display my PopUpMessage string from viewmodel. Here is my code.
XAML:
<xct:Popup.BindingContext>
<viewmodels:ProviderApplicationViewModel />
</xct:Popup.BindingContext>
<StackLayout Style="{StaticResource PopupLayout}">
<Label Style="{StaticResource Title}"
Text="Application Status" />
<BoxView Style="{StaticResource Divider}" />
<Label Style="{StaticResource Content}"
Text="{Binding PopUpMessage}"
TextColor="Black"/>
<Button Text="OKAY"
Style="{StaticResource ConfirmButton}"
Clicked="Button_Clicked" />
</StackLayout>
Code Behind:
public partial class ProviderApplicationPopup : Popup
{
public ProviderApplicationPopup()
{
InitializeComponent();
}
void Button_Clicked(object sender, System.EventArgs e) => Dismiss(null);
}
ViewModel:
private string popupmessage;
public string PopUpMessage
{
set { SetProperty(ref popupmessage, value); }
get { return popupmessage; }
}
ViewModel Popup Navigation:
if (response == "True")
{
PopUpMessage = "Your application has been submitted!";
Navigation.ShowPopup(new ProviderApplicationPopup());
IsBusy = false;
return;
}