Hi All,
I use a class to create StackLayout as given below ( Code to create Stacklayout ). The problem I'm facing is that I can't use this class twice to create the StackLayout using same class.
For example if I navigate from pages A --> B --> C --> D -- > A . When I use page A for first time I can add the stacklayout, but when I navigate second time to page A It shows as blank page.
Add Stacklayout to Page A
StackLayout content = new StackLayout ();
LandscapeViewCreator creator = new LandscapeViewCreator ();
await creator.SetCurrentView ();
content .Children.Clear ();
content .Children.Add (creator.CurrentView );
Code to create Stacklayout:
public class LandscapeViewCreator:StackLayout
{
public StackLayout CurrentView { get; set; }
public LandscapeViewCreator()
{
}
async public void SetCurrentView ()
{
//Create StackLayout and Set it to CurrentView
StackLayout CurrentView = new StackLayout ();
Label label = new Label ();
label .BackgroundColor = Color.Black;
label .Text = "Land";
label .TextColor = Color.White;
CurrentView.Children.Add (label );
}
}
I have tried removing Stacklayout from it's parent but It's not working. What could be the problem?? and how can I make it right. Thanks In advance..