xamarin - 如何在 C# 中为 ContentPage 设置 Shell.NavBarIsVisible="false"?
问题描述
这是我拥有的 XAML:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
Shell.NavBarIsVisible="false"
xmlns ="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Test.ABC" >
我正在尝试在 C# 中重新创建它,但遇到了一个问题,因为这些方法都不起作用:
namespace Test
{
public partial class ABC : ContentPage
{
Shell.NavBarIsVisible = false;
public ABC()
{
Shell.SetNavBarIsVisible = false;
Shell.NavBarIsVisibleProperty = false;
有谁知道我如何在没有 XAML 文件的 C# 实现中做到这一点。
解决方案
您需要在 Method 中调用它们OnAppearing
在内容页面
protected override void OnAppearing()
{
base.OnAppearing();
Shell.SetTabBarIsVisible(this, false);
Shell.SetNavBarIsVisible(this, false);
}
注意:如果您只想在特定的 ContentPage 中隐藏 Tabbar 和 NavigationBar ,请不要忘记在离开页面时显示它们
protected override void OnDisappearing()
{
base.OnDisappearing();
Shell.SetTabBarIsVisible(this, true);
Shell.SetNavBarIsVisible(this, true);
}
推荐阅读
- random - 如何确定 mt19937 算法的大 O 复杂度
- ios - 使用类方法实例化 UITableViewCell 会有内存管理问题吗?
- python - 为什么 *args 不能从覆盖 int 的类传递给 super().__init__()?
- apache-spark - 如何在pyspark RDD中找到整列数据的总和?
- fastapi - 如何覆盖 pydantic 模型的验证消息
- c# - 自定义 Vision ONNX 模型停止使用 Windows 10 ML
- php - 如何在 WooCommerce 结帐中更改贝宝的下单按钮文本
- c - 将 int 转换为字符串,然后用转换后的元素填充数组
- javascript - 如果条件在此函数内,我该如何运行
- javascript - 将标题从 React Native 导航传递给标题组件