Я хочу динамически добавить две страницы (ShellContents) в мою оболочку LoginShell, но LoginShell.Current
всегда равно нулю?
{
public LoginShell(string page = null)
{
InitializeComponent();
ShellItem si = new ShellItem();
LoginShell.Current.Items.FirstOrDefault().Items.Add(new ShellContent {ContentTemplate = new DataTemplate(typeof(SignUpPage))});
}
}
LoginShell.Current - свойство только для чтения.
Обновление
Я реализовал следующий код для моего класса StartUpShell:
public partial class StartUpShell : Shell
{
public StartUpShell(string page)
{
InitializeComponent();
ShellContent content;
if(page == nameof(SignUpPage))
{
content = new SignUpPage();
}
else if(page == nameof(LoginPinPage))
{
content = new LoginPinPage();
}
else
{
content = new SignUpPage();
}
ShellSection shellSection = new ShellSection();
shellSection.Items.Add(new ShellContent() { Content = content });
CurrentItem = shellSection;
}
, но при установке переменной содержимого он вылетает с сообщением: ShellContent Content should be of type Page. Title , Route D_FAULT_ShellContent4