Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7825931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:12:21+00:00 2026-06-02T09:12:21+00:00

I am trying to display a hh:mm:ss format but i always get the full

  • 0

I am trying to display a hh:mm:ss format but i always get the full date displayed.

Is there something wrong / missing from my Convertor Class / Dependency Properties?
I only receive the Datetime.now display, how to change this to 00:00:00?

What i actually want is to display 00:00:00 as initialization. Later it increments trough timers.

XAML:

<ListBox.ItemTemplate>
<DataTemplate>
    DownTime="{Binding DownTime, Converter={StaticResource  DateTimeConverter}, 
    ConverterParameter=\{0:hh:mm:ss\}}
</DataTemplate>
</ListBox.ItemTemplate>

Dependency Properties:

public static readonly DependencyProperty DownTimeProperty =
    DependencyProperty.Register("DownTime", typeof(DateTime), typeof(RegistrationButton), new UIPropertyMetadata(DateTime.Now));

public DateTime DownTime
    {
        get { return (DateTime)GetValue(DownTimestandProperty); }
        set { SetValue(DownTimeProperty, value); }
    }

Convertor class:

    [ValueConversion(typeof(DateTime), typeof(String))]
public class DateTimeConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        DateTime dt = (DateTime)value;
        return dt;

    }

    // No need to implement converting back on a one-way binding 
    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        string strValue = value as string;
        DateTime resultDateTime;
        if (DateTime.TryParse(strValue, out resultDateTime))
        {
            return resultDateTime;
        }
        return DependencyProperty.UnsetValue;
    }
}

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T09:12:22+00:00Added an answer on June 2, 2026 at 9:12 am

    You can just use StringFormat

    <TextBlock Text="{Binding DownTime, StringFormat={}{0:"hh:mm:ss"}}" />
    

    EDIT

    DateTime Represents an instant in time, typically expressed as a date and time of day.

    TimeSpan Represents a time interval.

    They have many similar methods, especially the ones to add or remove hours/mins/seconds and I think that’s what you want for this case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to display my Date field from my MySQL database. format is 2012-01-01
While trying to transform the date format I get an exception:unparseable date and don't
I am trying to display a window from service but don't getting it how
I am trying to format a string to display two columns for a high
I am trying to format an array of numbers to display in an array
Trying to display current time with PHP (using this ): $date = date('m/d/Y h:i:s
I am trying to display data that I am getting from server through json.
Using report Builder 7.x I am trying to format a TDBText to display postive
i'm trying to display an image from the database in an ASP.NET web page.
I am trying to display money numbers to users in a readable format. At

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.