xaml – Xamarin表单 – 显示工具栏项目中的取消按钮而不是后退(iOS)

xaml – Xamarin表单 – 显示工具栏项目中的取消按钮而不是后退(iOS),第1张

概述我想将iOS上NavigationBar中的标准后退按钮更改为取消按钮,如iOS中的“新建联系人”屏幕. 我正在使用Xamarin Forms. 编辑: 模态的XAML <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winf 我想将iOS上Navigationbar中的标准后退按钮更改为取消按钮,如iOS中的“新建联系人”屏幕.
我正在使用Xamarin Forms.

编辑:

模态的XAML

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"              x:Class="Xrm.Mca.VIEws.MyModalVIEw">    <ContentPage.toolbaritems>            <ToolbarItem x:name="Cancel" Text="Cancel" ></ToolbarItem>              <ToolbarItem x:name="Save" Text="Save" ></ToolbarItem>      </ContentPage.toolbaritems>    <ContentPage.Content>        <tableVIEw Intent="Form">            <tableRoot>                <tableSection title="Details">                    <EntryCell Label="name" Placeholder="Entry your name" />                    <EntryCell Label="Age" Placeholder="Entry your age" />                </tableSection>            </tableRoot>        </tableVIEw>    </ContentPage.Content></ContentPage>

在之前的屏幕中打开模态的代码隐藏

async Task OpenModal(){    var page = new NavigationPage(new MyModalVIEw ());    await App.Current.Navigation.PushModalAsync (page);}
解决方法 完成请求的标准惯例是 push a Modal并使用 ToolBarItems.您可以在 Xamarin Forums上找到将ToolbarItem应用于页面的示例.

如果你需要一个更具体的例子,请告诉我.

更新实例

这两个ToolbarItem就像这样:

var cancelitem = new ToolbarItem{    Text = "Cancel"};var doneItem = new ToolbarItem{    Text = "Done"};

现在您可以将这些添加到您的视图中:

this.toolbaritems.Add(cancelitem);this.toolbaritems.Add(doneItem);

你甚至可以绑定CommandProperty:

doneItem.SetBinding(MenuItem.CommandProperty,"DoneClicked");

或者只需在用户点击项目时处理事件:

doneItem.Clicked += (object sender,System.EventArgs e) => {    // Perform action};

请记住wrap your Modal in a NavigationPage,否则不会出现ToolbarItem.

希望这可以帮助.

总结

以上是内存溢出为你收集整理的xaml – Xamarin表单 – 显示工具栏项目中的取消按钮而不是后退(iOS)全部内容,希望文章能够帮你解决xaml – Xamarin表单 – 显示工具栏项目中的取消按钮而不是后退(iOS)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1068418.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存