ComponentOne DateTimeEditors for WPF and Silverlight
Specifying the Current Time
C1TimeEditor Control Help > C1TimeEditor Task-Based Help > Specifying the Current Time

You can specify the current time of a C1TimeEditor control by setting the C1TimeEditor.Value property in the designer, in XAML, and in code.

Note: Try to avoid setting the Value property in XAML as a string value. Parsing these values from strings is culture specific. If you set a value with your current culture and a user is using different culture, the user can get XamlParseException when loading your site. The best practice is to set these values from code or via data binding.

 

In the Designer

Complete the following steps:

  1. Click the C1TimeEditor control once to select it.
  2. In the Properties window, set the Value property to " 07:00:00". The control reflects a time of 7:00:00 a.m.

In XAML

To specify the current time, place Value="07:00:00" to the <my:C1TimeEditor> tag so that the markup resembles the following:

<my:C1TimeEditor Value="07:00:00"/>

The control reflects a time of 7:00:00 a.m.

In Code

Complete the following steps:

  1. Open the Window1.xaml.cs page.
  2. Place the following code beneath the InitializeComponent() method:

    Visual Basic
    Copy Code
    C1TimeEditor1.Value = New TimeSpan(7, 0, 0)
    

     

    C#
    Copy Code
    c1TimeEditor1.Value = new TimeSpan(7,0,0);
    

     

  3. Run the project and observe that control reflects a time of 7:00:00 a.m.

This Topic Illustrates the Following:

By following the steps in this topic, you have changed the time on the C1TimeEditor control to 7:00:00 a.m. The result will resemble the following: