locked
Refreshing the application after closing settings flyout.

    Question

  • Hello.

    In my application I use the settings flyout which contains some settings to change the looking of the page. The problem is that I have to check the local settings before changing any properties and I can do it only after loading the page. How can I "refresh" the page after closing the settings flyout and check the local settings to change some properties like colors, or size of the objects?

    Wednesday, February 19, 2014 10:05 PM

Answers

  • So what you're doing it checking the values of those settings every so often from the main page? That's interesting.  So that makes me think that you could have a custom static class for colors in your App.XAML.cs page which implements INotifyPropertyChanged.  Bind the controls to the static class.  When the color property changes, it will notify the controls which are bound it to and you won't have to check every 50 ms.  Let me know if you need help with this.


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, March 06, 2014 6:01 PM
    Moderator

All replies

  • You can refresh the page by calling Frame.Navigate again.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, February 20, 2014 1:26 PM
    Moderator
  • Ok, I used DispatcherTimer to check settings while moving the slider. Now the colors of objects change dynamicly in the same time. Can I access the objects from MainPage from settings flyout? That would be probably more clever.
    Thursday, February 20, 2014 3:53 PM
  • What in the page do you want to access?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, February 20, 2014 6:41 PM
    Moderator
  • I just want to change the color of the button.
    Monday, February 24, 2014 7:08 PM
  • You could change it if you made the button static in the code-behind.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, February 24, 2014 7:17 PM
    Moderator
  • Ok, could you explain me how can I make a button static?
    Tuesday, February 25, 2014 6:21 PM
  • Actually, I think that it would be a better idea to pass a parameter into the Frame.Navigate page call that sets the color of the button.  This would prevent the need for a static button. Like this:

    In Settings Flyout, get the color you want, then call the Frame.Navigate to the mainpage and pass in the color:

    Color C = Colors.Blue;
    Frame.Navigate(typeof(MainPage),C);

    In Mainpage, handle the OnNavigatedTo event:

    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
      if (e.Parameter != null) 
      {
        Color NewButtonColor = (Color) e.Parameter;
        MyButton.Background = new SolidColorBrush(NewButtonColor);
      }
    }


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, March 06, 2014 3:37 PM
    Moderator
  • But then, the color will change after closing the flyout, and I would like to change it as I move the slider. I used DispatcherTimer to change the color every 50 ms, and now it works, but I'm afraid that the load of CPU may be to high because of that.
    Thursday, March 06, 2014 4:00 PM
  • Ok gotcha...  you're changing it every 50ms to a new and different color? What kind of CPU utilization are you seeing with this? Why are you changing it so often? I guess I don't really get the scenario.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, March 06, 2014 4:15 PM
    Moderator
  • I would like to use the slider in the flyout to change the color of some elements. I can't acces those elements, but I want them to change in the same time I move the slider.Do you understand? I want the elements to change when I move the slider. Not after closing the flyout. That's why I check the localsettings so often, to make it smooth. The CPU load increases to 15%(i5 3570K). I know that that way is quite unintelligent, but I don't know how to do it better.
    Thursday, March 06, 2014 4:31 PM
  • So what you're doing it checking the values of those settings every so often from the main page? That's interesting.  So that makes me think that you could have a custom static class for colors in your App.XAML.cs page which implements INotifyPropertyChanged.  Bind the controls to the static class.  When the color property changes, it will notify the controls which are bound it to and you won't have to check every 50 ms.  Let me know if you need help with this.


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, March 06, 2014 6:01 PM
    Moderator
  • I have to read about INotifyPropertyChanged. I'll try to do it in that way. Thank you for your help.
    Thursday, March 06, 2014 8:10 PM