locked
[MetroApp/C++/XAML] How to refresh all the elemnts inside a Grid in a Page

    Question

  • I have a Page with two Grids.

    In the first Grid, I have Title, BackButton, and Reset Button.

    In the second grid, I have couple of toggle switches.

    When the Page loads firs time, the toggles switches load to default values, as get from the loaded functions, which are set in page.xaml (Loaded="load_toggleswitch"), and defined in the page.cpp.

    User is able to change these toggle switches.

    When user clicks the Reset Button, toggle switches set to default values.

    How can I achieve that.

    Is there any way to generate Load event for all the toggle switches in Grid 2?

    Thanks,

    Ashok M

    Friday, March 22, 2013 6:41 AM

Answers

  • You can try by navigating the same page again with disabling NavigationCacheMode.
    • Proposed as answer by Jesse Jiang Wednesday, March 27, 2013 1:38 AM
    • Marked as answer by Jesse Jiang Thursday, March 28, 2013 1:33 AM
    Friday, March 22, 2013 3:37 PM
  • I have a Page with two Grids.
    In the first Grid, I have Title, BackButton, and Reset Button.
    In the second grid, I have couple of toggle switches.
    When the Page loads firs time, the toggles switches load to default values...
    User is able to change these toggle switches.
    When user clicks the Reset Button, toggle switches set to default values.

    How can I achieve that.

    I wrote a sample application based on your question and blogged about it - the sample contains principles applied in the http://Hilo.CodePlex.com project.  
    The blog link follows: http://global-webnet.com/blog/post/2013/03/22/CppCX-XAML-and-data-binding.aspx

    The following is a screenshot from the Blog - it is the XAML source for the MainPage.xaml file.   It demonstrates how you can use the Command and CommandParameter attributes to communicate with a view model.   This view model contains properties for ButtonCommand, CheckBox1, CheckBox2, and StatusResults which have XAML bindings below.

    Below I show the MainViewModel source that pertains to the ButtonCommand property - The ExecuteMethod (line 18 and 23 left pane) is what handles the button click ONLY IF the CanExecute method returns true - if it returns false then the button that it references is disabled.   Thus you'll find that the Reset button will be disabled if you do not have a check box selected.


    MCAD.NET C# - http://www.Global-webnet.com/Blog

    • Proposed as answer by Jesse Jiang Wednesday, March 27, 2013 1:38 AM
    • Marked as answer by Jesse Jiang Thursday, March 28, 2013 1:33 AM
    Saturday, March 23, 2013 12:31 AM
  • Hi,

    I marked these replies as answer, if your issue has not been solved please unmark it and update more information about this issue.

    Best regards,
    Jesse


    Jesse Jiang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by ashok.m Wednesday, May 1, 2013 9:58 AM
    Thursday, March 28, 2013 1:34 AM

All replies

  • You can try by navigating the same page again with disabling NavigationCacheMode.

    Friday, March 22, 2013 3:26 PM
  • You can try by navigating the same page again with disabling NavigationCacheMode.
    • Proposed as answer by Jesse Jiang Wednesday, March 27, 2013 1:38 AM
    • Marked as answer by Jesse Jiang Thursday, March 28, 2013 1:33 AM
    Friday, March 22, 2013 3:37 PM
  • I have a Page with two Grids.
    In the first Grid, I have Title, BackButton, and Reset Button.
    In the second grid, I have couple of toggle switches.
    When the Page loads firs time, the toggles switches load to default values...
    User is able to change these toggle switches.
    When user clicks the Reset Button, toggle switches set to default values.

    How can I achieve that.

    I wrote a sample application based on your question and blogged about it - the sample contains principles applied in the http://Hilo.CodePlex.com project.  
    The blog link follows: http://global-webnet.com/blog/post/2013/03/22/CppCX-XAML-and-data-binding.aspx

    The following is a screenshot from the Blog - it is the XAML source for the MainPage.xaml file.   It demonstrates how you can use the Command and CommandParameter attributes to communicate with a view model.   This view model contains properties for ButtonCommand, CheckBox1, CheckBox2, and StatusResults which have XAML bindings below.

    Below I show the MainViewModel source that pertains to the ButtonCommand property - The ExecuteMethod (line 18 and 23 left pane) is what handles the button click ONLY IF the CanExecute method returns true - if it returns false then the button that it references is disabled.   Thus you'll find that the Reset button will be disabled if you do not have a check box selected.


    MCAD.NET C# - http://www.Global-webnet.com/Blog

    • Proposed as answer by Jesse Jiang Wednesday, March 27, 2013 1:38 AM
    • Marked as answer by Jesse Jiang Thursday, March 28, 2013 1:33 AM
    Saturday, March 23, 2013 12:31 AM
  • Thanks BillKrat.

    I will try your soln, and comb back to you.

    -ashok m

    Monday, March 25, 2013 6:31 AM
  • Hi,

    I marked these replies as answer, if your issue has not been solved please unmark it and update more information about this issue.

    Best regards,
    Jesse


    Jesse Jiang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by ashok.m Wednesday, May 1, 2013 9:58 AM
    Thursday, March 28, 2013 1:34 AM