WPF Multibinding String Formatting Date

I am trying to combine 2 fields of information in my grid using Multibinding, multitasking works fine, but I am having problems when I try to start generating 1 field, which is the date in this binding.

The 2 fields represent the Initials of users, that is, EGJ and the date of entry, hoping to achieve a combined field similar to "EGJ-01/01/2011"

Below I am with my existing XAML

<tk:DataGridTextColumn.Binding> <MultiBinding StringFormat=" {0} - {}{1:dd/MM/yyyy}"> <Binding Path="UserInitials" /> <Binding Path="EntryDate" /> </MultiBinding> </tk:DataGridTextColumn.Binding> 

Any help or pointers are most appreciated

+7
source share
2 answers

Could not see tree for trees

Just removing empty braces solved my problem.

 <tk:DataGridTextColumn.Binding> <MultiBinding StringFormat=" {0} - {1:dd/MM/yyyy}"> <Binding Path="UserInitials" /> <Binding Path="EntryDate" /> </MultiBinding> </tk:DataGridTextColumn.Binding> 

Thanks to everyone who took the time to watch.

+17
source

If you do not intend to have a leading space in a formatted value, you should use this binding instead:

 <tk:DataGridTextColumn.Binding> <MultiBinding StringFormat="{}{0} - {1:dd/MM/yyyy}"> <Binding Path="UserInitials" /> <Binding Path="EntryDate" /> </MultiBinding> </tk:DataGridTextColumn.Binding> 

If StringFormat starts with the left bracket { , then the XAML parser requires you to escape from it with a pair of curly braces {} . Otherwise, the parser gets confused because curly braces are also used in the syntax of markup extensions.

See the XAML documentation for {} Escape Sequence / Markup Extension for more details.

Perhaps you had the right evacuation sequence at the beginning of the format string and the things moved, resulting in an empty pair of curly braces in another place?

+4
source

All Articles