locked
accessing controls of content page

    Question

  • is it feasible to make content pages singleton? Because one may access it more than once, and everytime a new instance is created
    Monday, January 5, 2015 12:46 PM

Answers

  • A really key question is why do you want to access the content page control from another page?

    If you would like to modify the control while the app is running, use binding is the best way. Only one page is viewed by user when the app is running.

    If you would like to get some data from the control while the app is running, use binding too. We can bind data to some model and get data from that model.

    Besides binding, we can also save the value to the local setting, see: Quickstart: Local app data

    Or we can pass the value between pages via: Navigate(TypeName, Object) method

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, January 14, 2015 9:26 AM
    Moderator
  • Hi TJ24,

    Do not directly access to that page, if your page is automatically destroyed by system, how could you find that control via page? Instead use a local setting, when that page open again, assign the value directly to the ListBox.

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, January 22, 2015 2:16 PM
    Moderator

All replies

  • No reason it wouldn't work although it would probably be considered bad form.  Another way of doing it would be adding a reference to it in your App and accessing it via App::Current

    Monday, January 5, 2015 1:10 PM
  • then how do i access content page's control from other page?
    Monday, January 5, 2015 4:03 PM
  • If you keep a reference to your shared page in App

    var app = (App)Application.Current;
    var button = app.SharedPage.FindName("MyCoolButton");

    Monday, January 5, 2015 4:42 PM
  • A really key question is why do you want to access the content page control from another page?

    If you would like to modify the control while the app is running, use binding is the best way. Only one page is viewed by user when the app is running.

    If you would like to get some data from the control while the app is running, use binding too. We can bind data to some model and get data from that model.

    Besides binding, we can also save the value to the local setting, see: Quickstart: Local app data

    Or we can pass the value between pages via: Navigate(TypeName, Object) method

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, January 14, 2015 9:26 AM
    Moderator
  • Thanks for replying. I want to change the selection of the listbox of content page through the button click event of a button placed on mainpage.

    Tuesday, January 20, 2015 9:14 AM
  • Hi TJ24,

    Do not directly access to that page, if your page is automatically destroyed by system, how could you find that control via page? Instead use a local setting, when that page open again, assign the value directly to the ListBox.

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, January 22, 2015 2:16 PM
    Moderator