WPF format DateTime in TextBlock?

There is a string format property available when you are declaring the binding:

<TextBox Text="{Binding Path=DateTimeValue, StringFormat=dd-MM-yyyy}" />

(You need to be on .NET 3.5 SP1 for this property to exist)


If you want to use a common format string between bindings, you could declare the binding like this:

<Textbox Text={Binding Path=DateTimeValue, StringFormat={x:Static local:Constants.DateTimeUiFormat}} />

With your constants class like this:

public static class Constants
{
    public const string DateTimeUiFormat = "dd/MM/yyyy";

    //etc...
}