2
數據形這可能是有一個簡單的答案,但我有隻格式化數據形場的日期問題..日期格式使用數據註解在Silverlight
<df:DataForm x:Name="Form1" ItemsSource="{Binding Mode=OneWay}" AutoGenerateFields="True"
AutoEdit="True" AutoCommit="False"
CommitButtonContent="Save"
CancelButtonContent="Cancel"
CommandButtonsVisibility="Commit"
LabelPosition="Top" ScrollViewer.VerticalScrollBarVisibility="Disabled"
EditEnded="NoteForm_EditEnded">
<df:DataForm.EditTemplate>
<DataTemplate>
<StackPanel>
<df:DataField>
<TextBox Text="{Binding Title, Mode=TwoWay}"/>
</df:DataField>
<df:DataField>
<TextBox Text="{Binding Description, Mode=TwoWay}" AcceptsReturn="True" HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto" Height="" TextWrapping="Wrap" SizeChanged="TextBox_SizeChanged"/>
</df:DataField>
<df:DataField>
<TextBlock Text="{Binding Username}"/>
</df:DataField>
<df:DataField>
<TextBlock Text="{Binding DateCreated}"/>
</df:DataField>
</StackPanel>
</DataTemplate>
</df:DataForm.EditTemplate>
</df:DataForm>
我已綁定這
/// <summary>
/// Gets or sets the date created of the noteannotation
/// </summary>
[Display(Name="Date Created")]
[Editable(false)]
[DisplayFormat(DataFormatString = "{0:u}", ApplyFormatInEditMode = true)]
public DateTime DateCreated { get; set; }
不管我設置dataformatstring它回來爲:具有現場dateCreated會批註筆記類如2010/4/6上午10時02分15秒
我想這格式化爲yyyy-MM-dd HH:mm:ss
我試過上面的自定義格式{0:yyyy-MM-dd hh:mm:ss},但它仍然是相同的輸出。 {0:u}或{0:s}也是如此。