title: TimePicker UWP Basics
body: <p>Having some problems with a simple clock application I am trying to write.  Very new to UWP and C# so patience is greatly appreciated.  Took source from <a href="https://github.com/kd4gar/Windows-Core-IOT-Clock" rel="nofollow noreferrer">https://github.com/kd4gar/Windows-Core-IOT-Clock</a></p>
  
  <p>What I am trying to do is have the clock font/brightness autodim at night based upon set time.  So I am using TimePicker</p>
  
  <p>In the Settings.XAML I have a few other settings (24 hour clock, etc) and the settings page works, I have these two items:</p>
  
  <p></p>
  
  <p></p>
  
  <p>In my .xaml.cs  I have this code.  I am trying to save it to settings, or set the default values to 7:00 AM and 17:00 AM.</p>
  
  <pre><code>    public DateTime DimDisplayStartTimeSetting
      {
          get
          {
  
              if (localSettings.Values["DimDisplayStartTimeSettingValue"] == null)
              {
                  localSettings.Values["DimDisplayStartTimeSettingValue"] = "7:00";
              }
              ///  return (localSettings.Values["DimDisplayStartTimeSettingValue"]);
              return (localSettings.Values["DimDisplayStartTimeSettingValue"]);
  
              localSettings.Values["DimDisplayStartTimeSettingValue"] = "7:00";
          }
  
          set
          {
              localSettings.Values["DimDisplayStartTimeSettingValue"] = value;
          }
      }
  
      public DateTime DimDisplayStopTimeSetting
      {
          get
          {
  
              if (localSettings.Values["DimDisplayStopTimeSettingValue"] == null)
              {
                  localSettings.Values["DimDisplayStopTimeSettingValue"] = "17:00";
              }
              /// return TimeSpan.Parse(localSettings.Values["DimDisplayStopTimeSettingValue"].ToString());
  
          }
  
          set
          {
              localSettings.Values["DimDisplayStopTimeSettingValue"] = value;
          }
      }
  </code></pre>
  
  <p>I seem to be doing something wrong, specifically around using DateTime vs TimeSpan.  Could someone help me understand a bit better?  I've read through the docs on TimePicker and think I understand that it wants a TimeSpan, but not sure how to set it right in my Settings.xaml.cs.  Thanks!</p>