Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Datagrid time field format hh:mm

I use a WPF Toolkit Datagrid with a LINQ to SQL

       <my:DataGrid AutoGenerateColumns="False" Name="dataGrid2">
        <my:DataGrid.Columns>
            <my:DataGridTextColumn Header="Date" MinWidth="80"
                                       Binding="{Binding Date, StringFormat=d}"
                                       CanUserSort="False"/>
            <my:DataGridTextColumn Header="Time"  MinWidth="70" 
                                       Binding="{Binding Time}"
                                       CanUserSort="False" />
            <my:DataGridTextColumn Header="Description" MinWidth="200"
                                       Binding="{Binding Description}" 
                                       CanUserSort="False"/>
        </my:DataGrid.Columns>
    </my:DataGrid>

Column Time is bound to a SQL Server table field of a Time datatype. Now time value on the Datagrid is displayed in a format hh:mm:ss.

How could I change a time represantation in the Time column of a Datagrid to hh:mm, removing seconds?

EDIT: Using StringFormat=t gives no result.

<my:DataGridTextColumn Header="Time"  MinWidth="70" 
                                       Binding="{Binding Time, StringFormat=t}"
                                       CanUserSort="False" />
like image 837
rem Avatar asked Mar 04 '10 06:03

rem


1 Answers

<toolkit:DataGridTextColumn
                    IsReadOnly="True"
                    Width="SizeToCells"
                    Header="F. Resolución"
                    Binding="{Binding ColName, StringFormat=MM/dd/yyyy}" />
like image 75
Alexis Alulema Avatar answered Sep 20 '22 07:09

Alexis Alulema