简体   繁体   English

重新选择当前选项卡以刷新 Xamarin 社区工具包上 TabView 控件上的页面

[英]ReSelect the current tab to refresh the Page on TabView Control on Xamarin Community Toolkit

I am working on a Xamarin Forms App.我正在开发 Xamarin Forms 应用程序。 Everything is working correctly.一切正常。 I am working on a feature where user re-selects the current tab (This tab is already selected) and page should refresh.我正在开发一项功能,用户重新选择当前选项卡(此选项卡已被选中)并且页面应该刷新。

I am using TabView from Xamarin Community Toolkit.我正在使用 Xamarin 社区工具包中的 TabView。

There is on code to share as I am looking for some generic solution and my code is running correct.当我正在寻找一些通用解决方案并且我的代码运行正确时,有代码可以共享。

Is there any way we can write Custom Renderer for Xamarin Toolkit TabView to Re-Select the current tab?有什么方法可以为 Xamarin Toolkit TabView 编写自定义渲染器以重新选择当前选项卡?

Maybe you needn't use the custom renderer, you can try to use the TabView.SelectedIndex = to re-select the current tab.也许您不需要使用自定义渲染器,您可以尝试使用TabView.SelectedIndex =重新选择当前选项卡。 Such as:如:

In the xaml:在 xaml 中:

<xct:TabView TabStripPlacement="Bottom" IsSwipeEnabled="False"  x:Name="tabview">

In the page.cs:在 page.cs 中:

 private void Button_Clicked(object sender, EventArgs e)
    {
        tabview.SelectedIndex = 0;
    }

In addition, user re-select the current tab always by tapping the tabitem, so you can just refresh the page by doing something in the tapped event.此外,用户总是通过点击 tabitem 重新选择当前标签,因此您可以通过在点击事件中执行某些操作来刷新页面。 Such as:如:

In the xaml:在 xaml 中:

<xct:TabView TabStripPlacement="Bottom" IsSwipeEnabled="False"  x:Name="tabview">
        <xct:TabViewItem Text="Data" TabTapped="TabViewItem_TabTapped">
            
        </xct:TabViewItem>

In the page.cs在 page.cs

private void TabViewItem_TabTapped(object sender, Xamarin.CommunityToolkit.UI.Views.TabTappedEventArgs e)
    {
        //doing something
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 .MAUI:如何使用社区工具包标记或 C# 将上下文菜单添加到控件中 - .MAUI: How to add context menu into control by using community-toolkit-markup or C# Silverlight Datagrid刷新当前页面 - Silverlight Datagrid Refresh current page 将用户控件添加到标签页 - Add user control to tab page 谁能向我解释如何使用 Func<t, t, bool> ? validateValue = null) Xamarin 社区工具包 ObservableObject 中的验证?</t,> - Can anyone explain to me how I can use Func<T, T, bool>? validateValue = null) validation in the Xamarin Community Toolkit ObservableObject? ajax控件工具包的选项卡容器(将选项卡标题移到右侧) - ajax control toolkit's tab container(shifting tab header to right side) 为什么标签页主体没有使用.NET选项卡控件进行更新? - Why is the tab page body not updating with a .NET tab control? .Net Maui Community Toolkit 在运行时更改 TintColor - .Net Maui Community Toolkit Change TintColor at runtime 选项卡控件类,具有2种通用类型的选项卡和页面彼此链接 - Tab control class with 2 generic types for tab and page that link to each other AJAX 控制工具包问题 - AJAX Control Toolkit issue 如何以编程方式将PictureBox控件添加到选项卡页面控件 - How to programmatically add PictureBox control to the tab page control
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM