Hello
I have a XamDataCards object that takes a custom Person object as its DataSource.
Person object has a number of public fields. One of them is FullAddress which is of type string and the value contains new line delimiters "\r\n".
Can I somehow format the field value cell of the DataCard to display the FullAddress text in multiple lines?
For example, if the value is
"Home House \r\n 31 Low Street \r\n London \r\n SW5 7NL"
to display it as
"Home House
31 Low Street
London
SW5 7NL"
in the cell.
Many thanks.
Kostas.
Hello Kostas,
By default the CellValuePresenter will display the text on multiple lines. The issue is that the size of the CellValuePresenter for the field is not large enough to display all of the text. The easiest way to resolve this is to set the Height for the field:
<igDP:XamDataCards.FieldLayouts>
<igDP:FieldLayout>
<igDP:Field Name="ID"/>
<igDP:Field Name="Name"/>
<igDP:Field Name="FullAddress" Height="50"/>
</igDP:FieldLayout>
</igDP:XamDataCards.FieldLayouts>
In theory you could also bind the Height property to the value of the field and use a converter to determine how large it should be based off of the amount of new line characters are in the text along with the font size of the text. This could prevent the fields being too large though all cards would have the same height for the FullAddress field.
Hi Jason ,
Changing Height of the field as per the number of newline characters in the field text would be much difficult because we have to write converter and calculate number of new lines and multiply that count with minimum height.
Here i'm proposing a solution which doesn't require any converter. simply change the Control Template of the CellValuePresenter:
<Style x:Uid="Style_1" TargetType="{x:Type igDP:CellValuePresenter}">
<Setter Property="Template" >
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
<TextBlock Height="Auto" Text="{TemplateBinding Content}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Regards
Sanath