嘿大家好日子我在xaml中创建了tabbed,我更喜欢xaml,因为我登录了xaml代码。我的代码
Tab.xaml
<TabbedPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:FormsSample.Views;assembly=FormsSample"
x:Class="FormsSample.Views.LoginPage"
x:Name="TbPage">
<TabbedPage.Children>
<ContentPage x:Name="TbLog" Title="Login">
</ContentPage>
<ContentPage x:Name="TbSch" Title="Schedule">
</ContentPage>
<ContentPage x:Name="TbLis" Title="Customers">
</ContentPage>
</TabbedPage.Children>
</TabbedPage>
Tab.xaml.cs
namespace FormsSample.Views
{
public partial class LoginPage : TabbedPage
{
private readonly TabbedPage _tbPage;
private readonly ContentPage _tbList;
private readonly ContentPage _tbLogn;
public LoginPage()
{
InitializeComponent ();
_tbPage = this.FindByName<TabbedPage>("TbPage");
_tbList = this.FindByName<ContentPage>("TbLis");
_tbLogn = this.FindByName<ContentPage>("TbLog");
RunTime();
}
private void RunTime()
{
_tbPage.CurrentPage = _tbLogn;
if (_tbPage.SelectedItem == _tbPage.Children[2])
{
DisplayAlert("Tab", "Hello World", "OK");
}
}
}
}
更改为
_tbPage.SelectedItem == _tbList
它的类似没有任何反应,如何解决这个问题?非常感谢。
答案 0 :(得分:1)
这可能不太花哨但对我有用:D
this.CurrentPageChanged += (o, e) =>
{
var i = this.Children.indexOf(this.CurrentPage);
if(i == 1 && UsrType == 2)
{
DisplayAlert("Admin", "Administrator Privilege required!", "OK");
this.CurrentPage = _tbLog;
}
};
答案 1 :(得分:1)
在将SelectedItem
设置为要显示的页面之前,我先将null
设置为public function dtrdata(){
$totalnumdays = 31; //31
$firstdaynum = 4; //6 max // convert day to num
$reset = 0;
$weekdays = array('Mon','Tue','Wed','Thu','Fri','Sat','Sun');
for($i=1;$i<=$totalnumdays;$i++){
for($x=0; $x<count($weekdays); $x++){
$index = $firstdaynum+$reset; //fri start; index in array
if($index == 6){
$reset = $firstdaynum * -1;
}else{
$reset++;
}
break;
}
}
return view('pages/admin', compact('i'));
}
//Views
<tr>
<td>{{ i}}</td>
</tr>
。