0

for testing purposes i created a simple object-list. I display the data in a datagrid with this code:

<DataGrid x:Name="dataGrid1" 
          IsReadOnly="True" 
          HorizontalAlignment="Left" 
          Margin="50,30,0,0" 
          VerticalAlignment="Top" 
          Height="251" 
          Width="544" 
          AutoGenerateColumns="False">
    <DataGrid.Columns>
        <DataGridTextColumn Header="Name" Binding="{Binding Birthday}" />
    </DataGrid.Columns>
</DataGrid>

This works great, but my birthday is a datatype DateTime so how can i modify this bound data? I just want to show the DateTime.toShortDateString() value.

1

1 Answer 1

1

You need to use the StringFormat in your binding.

<TextBlock Text="{Binding Date, StringFormat='{}{0:dd.MM.yyyy}'}" /> // 16.12.2016

See this answer.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.