Note that there are some explanatory texts on larger screens.

plurals
  1. POConverter --> Convert DateTime to HH:mm:ss format
    primarykey
    data
    text
    <p>I am trying to display a hh:mm:ss format but i always get the full date displayed.</p> <p>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?</p> <p>What i actually want is to display 00:00:00 as initialization. Later it increments trough timers. </p> <p><strong>XAML:</strong></p> <pre><code>&lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; DownTime="{Binding DownTime, Converter={StaticResource DateTimeConverter}, ConverterParameter=\{0:hh:mm:ss\}} &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; </code></pre> <p><strong>Dependency Properties:</strong></p> <pre><code>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); } } </code></pre> <p><strong>Convertor class:</strong></p> <pre><code> [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; } } </code></pre> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload