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 7979983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:55:48+00:00 2026-06-04T09:55:48+00:00

For some reason using Content={Binding Time, StringFormat=t} is still giving me a long date.

  • 0

For some reason using Content="{Binding Time, StringFormat=t} is still giving me a long date. The backing field is a DateTime property initialised with DateTime.Now but no matter what string format I try it still shows the full date…

I would like only to see HH:mm tt

Any ideas?

XAML :

<Window x:Class="ArgosSystem.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:loc="clr-namespace:ArgosSystem"
        xmlns:sys="clr-namespace:System;assembly=System"
        Title="MainWindow" Height="800" Width="1280" Loaded="Window_Loaded">
    <Window.Resources>
        <DataTemplate DataType="{x:Type loc:Picknote}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="200" MinWidth="200" />
                    <ColumnDefinition Width="350" />
                    <ColumnDefinition Width="250" />
                    <ColumnDefinition Width="50" />
                </Grid.ColumnDefinitions>
                <Label Content="{Binding Time, StringFormat=t}" VerticalContentAlignment="Center"  Foreground="IndianRed" FontSize="36" Grid.Column="0" />
                <Label Content="{Binding Customer}" VerticalContentAlignment="Center" Foreground="IndianRed" FontSize="36" Grid.Column="1" />
                <Label Content="{Binding PicknoteNo}"  VerticalContentAlignment="Center"  Foreground="IndianRed" FontSize="36" Grid.Column="2" />
                <Label Content="{Binding Qty}"  VerticalContentAlignment="Center"  Foreground="IndianRed" FontSize="36" Grid.Column="3" />
            </Grid>
        </DataTemplate>
    </Window.Resources>
    <Grid Background="Black">
        <DockPanel>
            <ScrollViewer Name="lstPicknoteScroll" VerticalScrollBarVisibility="Auto">
                <ItemsControl Name="lstPicknotes" ItemsSource="{Binding}"  IsTabStop="False" Foreground="Cornsilk" />
            </ScrollViewer>
        </DockPanel>
    </Grid>
</Window>

C# :

public partial class MainWindow : Window
{
    ObservableCollection<Picknote> picknotes = new ObservableCollection<Picknote>();

    public MainWindow()
    {
        InitializeComponent();
        lstPicknotes.DataContext = picknotes;
    }

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        picknotes.Add(new Picknote
        {
            Time = DateTime.Now,
            Customer = "REED FOR SPEED",
            PicknoteNo = "PKN767677",
            Qty = 100
        });

        picknotes.Add(new Picknote
        {
            Time = DateTime.Now.AddHours(-2),
            Customer = "F1 AUTOMOTIVE",
            PicknoteNo = "PKN767677",
            Qty = 50
        });
        picknotes.Add(new Picknote
        {
            Time = DateTime.Now.AddHours(-1),
            Customer = "FERGUSENS",
            PicknoteNo = "PKN767677",
            Qty = 10
        });
    }
}
  • 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-04T09:55:50+00:00Added an answer on June 4, 2026 at 9:55 am

    StringFormat works on properties of type string. The Content property is of type Object so you need to specify the format using ContentStringFormat property of Label control.

    <Label Content="{Binding Time}" ContentStringFormat="t" VerticalContentAlignment="Center"  Foreground="IndianRed" FontSize="36" Grid.Column="0" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using inline Fancybox for the first time and for some reason I'm not
For some reason, Vim keeps using soft-tabs (tabs as spaces) everytime I'm working on
I am using Visual studio 2008 and for some reason when I started today
I am using IntelliJ for my Android development and for some reason it is
For some reason that I don't understand, video websites do not play when using
Im using oslib with the pspsdk toolchain and for some reason this doesnt work
I have just tried using the NSArchiver but for some reason I am getting
When using eclipse on ubuntu, for some reason it crashes/stops responding when loading an
I'm working on writing a FileSystemWatcher using Mono but for some reason the callback
I've written Encryption/Decryption methods using the RC2CryptoServiceProvider in C# and for some reason, I

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.