profanis
profanis

Reputation: 2751

Label StringFormat doesn't work

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?

Upvotes: 1

Views: 2720

Answers (1)

Matěj Z&#225;bsk&#253;
Matěj Z&#225;bsk&#253;

Reputation: 17272

Put the contents of the label into a TextBlock

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

Upvotes: 7

Related Questions