如何在Xamarin.Forms中创建带有十字图标而不是返回按钮的页面?

如何在Xamarin.Forms中创建带有十字图标而不是返回按钮的页面?,xamarin,xamarin.forms,xamarin.android,xamarin.ios,Xamarin,Xamarin.forms,Xamarin.android,Xamarin.ios,发现我太新了,不能在Xamarin社区论坛上提问,希望能从这里得到一些想法。提前谢谢 当我浏览一些应用程序时,有些页面如下所示: 所以对于这类页面,它有一个“十字”图标而不是左箭头,当我点击十字图标,或者在对该页面进行操作后点击保存按钮时,页面从上到下逐渐淡出 对于普通的导航页面,它有返回按钮,通常从左到右淡出 那么通常什么时候使用这种页面呢?它仍然是一个导航页面吗?是否可以使用Xamarin.Forms实现这一点?有任何教程或学习示例吗?您可以通过模式页面实现这一点,我建议您使用 通过标签或

发现我太新了,不能在Xamarin社区论坛上提问,希望能从这里得到一些想法。提前谢谢

当我浏览一些应用程序时,有些页面如下所示:

所以对于这类页面,它有一个“十字”图标而不是左箭头,当我点击十字图标,或者在对该页面进行操作后点击保存按钮时,页面从上到下逐渐淡出

对于普通的导航页面,它有返回按钮,通常从左到右淡出


那么通常什么时候使用这种页面呢?它仍然是一个导航页面吗?是否可以使用Xamarin.Forms实现这一点?有任何教程或学习示例吗?

您可以通过模式页面实现这一点,我建议您使用

通过标签或图像按钮将X图标添加到弹出页面的左上角

如果使用标签添加TapGestureRecognizer,则使用按钮按下事件并关闭弹出窗口,如下所示

wait Rg.Plugins.Popup.Contracts.INavigation.Instance.popsync()
对于从上到下的渐变,您可以在这个nuget中使用

他们在github中提供了一些示例,您可以自己查看。

“页面从上到下逐渐淡出”听起来像是一个模式页面

使用标题视图

模式页面:

<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="XFormPlayground.CustomPushModelPage">
<NavigationPage.TitleView>
    <Grid>

        <Label
            Text="Add Timesheet"
            FontSize="Title"
            HorizontalOptions="Center"
            VerticalOptions="CenterAndExpand" />
        <Button
            Text="X"
            Command="{Binding PushModelCommand}"
            BackgroundColor="Transparent"
            WidthRequest="40"
            HorizontalOptions="Start" />

    </Grid>

</NavigationPage.TitleView>
<ContentPage.Content>
    <StackLayout>
        <Label
            Text="This is a modal page"
            VerticalOptions="CenterAndExpand"
            HorizontalOptions="CenterAndExpand" />
    </StackLayout>
</ContentPage.Content>
主页xaml:

<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="XFormPlayground.MainPage">

<StackLayout>
    <!--  Place new controls here  -->
    <Button
        x:Name="ViewModelPageButton"
        Clicked="ViewModelPageButton_OnClicked"
        VerticalOptions="Center"
        Text="Click" />
</StackLayout>

结果:


谢谢。我认为你的答案更接近我想要的,但莫尔斯的答案仍然是一个不错的选择。对于那些使用此方法但受到标题视图中内置填充的干扰的人,我指的是删除它。
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="XFormPlayground.MainPage">

<StackLayout>
    <!--  Place new controls here  -->
    <Button
        x:Name="ViewModelPageButton"
        Clicked="ViewModelPageButton_OnClicked"
        VerticalOptions="Center"
        Text="Click" />
</StackLayout>