Search Results

Search found 1 results on 1 pages for 'mythul'.

Page 1/1 | 1 

  • How to pass an object from a Frame to another Frame in a Windows 8 Style App

    - by Mythul
    I have problem that i just cant figure out right now. I am trying to develop a Windows-8 style app and im stuck implementing this functionality. I have a MainWindow which contains a ListBox and a Button (lets say addButton). When i click the button i navigate to a new page, lets say AddCustomerPage with this.Frame.Navigate(typeof (AddCustomerPage)); AddCustomerPage has 1 textBox and 1 button (lets say doneButton. When i click the button i want the string in the textBox to be added to the ListBox on the previous page. This is my current functionality: 1. MainWindow is created. Click addButton AddCustomer page is created. MainWindow is destroyed(problem). Click doneButton A MainWindow object is created with a ListBox with 1 item. Repeat the add process, i always get a MainWindow with a ListBox with 1 item. Thanks for the help. Here is the code: public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); this.brainPageController = new PageController(); // add items from the List<String> to the listBox listGoals.ItemsSource = brainPageController.GetListGoals(); } protected override void OnNavigatedTo(NavigationEventArgs e) { var parameter = e.Parameter as String; // a simple controller that adds a string to a List<string> brainPageController.AddGoal(parameter); } private void addButton_Click(object sender, RoutedEventArgs e) { this.Frame.Navigate(typeof (GoalsInfo)); } // VARIABLES DECLARATION private PageController brainPageController; } public sealed partial class GoalsInfo : WinGoalsWIP.Common.LayoutAwarePage { public GoalsInfo() { this.InitializeComponent(); this.brainPageController = new PageController(); } protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState) { } protected override void SaveState(Dictionary<String, Object> pageState) { } private void Button_Click_1(object sender, RoutedEventArgs e) { brainPageController.AddGoal(nameTextBox.Text); this.Frame.Navigate(typeof(MainPage), nameTextBox.Text); } // VARIABLES DECLARATION PageController brainPageController; }

    Read the article

1