4

为什么显示日期和时间(而不仅仅是日期)?

<ListView Name="AttachmentsLB" Width="160" ItemsSource="{Binding Path=PicuAttachments}" >
    <ListView.View>
        <GridView>
            <GridViewColumn Header="Start" DisplayMemberBinding="{Binding StartDate}" Width="80">
                <GridViewColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Path=., StringFormat=d}" />
                    </DataTemplate>
                </GridViewColumn.CellTemplate>
            </GridViewColumn>
            <GridViewColumn Header="Finish" DisplayMemberBinding="{Binding FinishDate}" Width="80">
                <GridViewColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Path=., StringFormat=d}" />
                    </DataTemplate>
                </GridViewColumn.CellTemplate>
            </GridViewColumn>
        </GridView>
    </ListView.View>
</ListView>

我也试过 StringFormat = {}{0:d} 和 StringFormat = \{0:d\} 没有成功

4

2 回答 2

0

StringFormat 在错误 Binding 上的问题

<GridViewColumn Header="Start" DisplayMemberBinding="{Binding StartDate, StringFormat=d}" Width="75">
    <GridViewColumn.CellTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding}" />
        </DataTemplate>
    </GridViewColumn.CellTemplate>
</GridViewColumn>
于 2013-01-25T05:01:07.503 回答
0

用这个怎么样?更改绑定中的 StringFormat :

DisplayMemberBinding="{Binding Path=startDate, StringFormat='yyyy-MM-dd'}"
于 2013-01-30T07:25:45.313 回答