我尝试更改BarBackgroundColor属性,但只有第一种情况是开关工作并设置紫色。 CurrentPageChanged事件正在触发但不更改背景颜色。另外如何改变单个标签背景的背景。
在我的public partial class Tabbed : TabbedPage
public void changeColorOfTabBar(int index)
{
switch (index)
{
case 0:
BarBackgroundColor = Color.FromHex(Constants.evrensel_purple);
break;
case 1:
BarBackgroundColor = Color.FromHex(Constants.evrensel_green);
break;
case 2:
BarBackgroundColor = Color.FromHex(Constants.evrensel_blue);
break;
default:
BarBackgroundColor = Color.FromHex(Constants.color_blue);
break;
}
}
public void createTabs(LoginResponse response)
{
Children.Add(new HomeTab(response) { Title = "Home", Icon = "home.png" });
Children.Add(new TimesheetTab(response) { Title = "Timesheet", Icon = "timesheet.png" });
Children.Add(new MyLeavesTab(response) { Title = "My Leaves", Icon = "leave.png", });
}
public Tabbed (LoginResponse response,LoggedInfo info)
{
InitializeComponent();
Title = "Welcome, " + _serviceEmployee.getEmployeeByUserId(response.userid).fullnameReplaced;
CurrentPageChanged += (sender, args) =>
{
var index = Children.IndexOf(CurrentPage);
changeColorOfTabBar(index);
};
createTabs(response);
res = response;
}