//// Model code:
public class FirstPageModel : FreshBasePageModel
{
public Command<SfPopupLayout> OpenAlertDialog { get; set; }
public FirstPageModel()
{
this.OpenAlertDialog = new Command<SfPopupLayout>(this.DisplayAlert);
}
private void DisplayAlert(SfPopupLayout popupLayout)
{
popupLayout.IsOpen = true;
}
}
//// Xaml code:
<ContentPage.Resources>
<ResourceDictionary>
<popuplayout:SfPopupLayout x:Key="AlertDialog">
<popuplayout:SfPopupLayout.PopupView>
<popuplayout:PopupView ShowHeader="False"
AcceptButtonText="DISCARD"
DeclineButtonText="CANCEL"
AppearanceMode="TwoButton"
HeightRequest="120" >
<popuplayout:PopupView.ContentTemplate>
<DataTemplate>
<Grid BackgroundColor="White" Padding="15,20,0,0">
<Label FontSize="16" BackgroundColor="White" TextColor="Gray" Text="Discard draft?"/>
</Grid>
</DataTemplate>
</popuplayout:PopupView.ContentTemplate>
</popuplayout:PopupView>
</popuplayout:SfPopupLayout.PopupView>
</popuplayout:SfPopupLayout>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<ScrollView x:Name="parentLayout">
<StackLayout Orientation="Vertical" Spacing="20" Padding="20" >
<Button x:Name="Alert"
Text="ALERT"
CornerRadius="5"
BackgroundColor="#0059ff"
TextColor="White"
HeightRequest="40"
Command="{Binding OpenAlertDialog}"
CommandParameter="{StaticResource AlertDialog}" />
</StackLayout>
</ScrollView>
</ContentPage.Content>
|