2016-12-16 4 views
0

私は単純なオブジェクトリストを作成しました。私はこのコードとデータグリッドでデータを表示:WPF DataGridはバインドされたデータを変更します。テスト用に

<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> 

これは素晴らしい作品が、私の誕生日はどのように私はこのバインドされたデータを変更することができますので、日時データ型のですか?私は、DateTime.toShortDateString()値を表示したいだけです。

+0

[WPFバインディングStringFormat短い日付文字列]の可能な複製(http://stackoverflow.com/questions/5046429/wpf-binding-stringformat-short-date-string) –

答えて

1

バインディングにStringFormatを使用する必要があります。

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

answerを参照してください。

関連する問題