我想在选择后更改标签图标和页面,我有 2 个页面,但我想用 1 个标签更改并在选择后更改图标和页面,我该怎么做?
public MainPage()
{
InitializeComponent();
var login = new NavigationPage(new login())
{
Title = "login",
Icon = "login.png"
};
var register = new NavigationPage(new register())
{
Title = "register",
Icon = "register.png"
};
if(CurrentPage is register)
{
Children.Add(login);
}
else
{
Children.Add(register);
}
this.CurrentPageChanged += (object sender, EventArgs e) =>
{
var i = this.Children.IndexOf(this.CurrentPage);
if (i == 0)
{
login.Title = "login";
login.Icon = "login.png";
}
else
{
register.Title = "register";
register.Icon = "register.png";
}
};