I have the following popup window defined:
The Codebehind:
public partial class SimplePopup : Popup
{
public SimplePopup()
{
InitializeComponent();
}
public SimplePopup(string message, string messagetype)
{
InitializeComponent();
TheMessage.Text = message;
if (messagetype == "ERROR")
{
TheMessage.BackgroundColor = Colors.Red;
} else if (messagetype == "INFO")
{
TheMessage.BackgroundColor = Colors.Green;
}
}
async void OnOKButtonClicked(object? sender, EventArgs e)
{
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5));
await CloseAsync(token: cts.Token);
}
}
The code to execute this popup is:
public async Task DisplayPopup(string message, string messageType)
{
SimplePopup popup = new(message, messageType)
{
CanBeDismissedByTappingOutsideOfPopup = false
};
await MainThread.InvokeOnMainThreadAsync(async () =>
{
await this.ShowPopupAsync(popup, null);
});
}
I’ve tried several methods to get the message to fill the entire popup area but thus far nothing works. What am I doing wrong?