Label StringFormat doesn't work

[亡魂溺海] 提交于 2019-12-24 09:28:41

问题


I am trying to format a {datetime?} property with stringFormat, but I don't know why it doesn't applied to.

this is my code

<DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
        <Grid>
            <Label Content="{Binding From, StringFormat='{}{0:dd.MM.yyyy}'}"/>
        </Grid>
    </DataTemplate>
</DataGridTemplateColumn.CellTemplate>

Am I doing something wrong?


回答1:


Put the contents of the label into a TextBlock

<Label>
    <TextBlock Text="{Binding Path=From, StringFormat='{}{0:dd.MM.yyyy}'}"/>
</Label>


来源:https://stackoverflow.com/questions/5068030/label-stringformat-doesnt-work

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!