[英]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.