Hello everyone,
I'm having some trouble getting the height of a grid row to correctly resize to the text label fitted within.
The label itself uses a custom renderer to ellipse the text, if it takes up more than two lines.
But it seems as though the height of the grid row still spaces to the full string of the text.
Secondly, the correct size is apparently "recalculated" and fixes itself after scrolling further down the list view.
Additional:
I use a datatemplateselector to pick the datatemplate for the listview entry.
Is there anyway for me to force this "recalculation" or just make it scale correctly in the first go?
I'm not allowed to post pictures sadly, not sure how to show you guys the problem, I have both pictures and a gif of it
Code for the renderer label
protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.LayoutChange += (s, args) =>
{
var baseLabel = (MultiLineLabel)this.Element;
Control.SetMinLines(0);
Control.Ellipsize = TextUtils.TruncateAt.End;
Control.SetMaxLines(baseLabel.Lines);
};
}
}
The grid that holds the multiline label
<Grid x:Name="detailGrid">
<Grid.RowDefinitions>
<RowDefinition Height="*" x:Name="detailLabelRow"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<CustomRenderers:MultiLineLabel x:Name="detailLabel"
HorizontalOptions="StartAndExpand"
FontSize="Small"
TextColor="Red"
Lines="2"/>
</Grid>
Any help would be greatly appreciated!
Thanks!