Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Right align label with a binding in RelativeLayout

$
0
0

Hi,

I'm displaying a label that should be right aligned in my RelativeLayout - but about 10% of the time it seems that the label doesn't align itself properly. Most of the time it works, but occasionally when viewing the page, it aligns itself past the edge of the screen, as if it didn't update after changing its binding content. Here is my code sample:

    TimeLabel = new Label
    {
        TextColor = StyleDefault.ContentAltTextColor,
        Font = StyleDefault.ContentAltFont,
        Text = "Time"
    };
    var timeValConverter = new TimeStringValueConverter();
    TimeLabel.SetBinding(Label.TextProperty, new Binding("time", BindingMode.OneWay, timeValConverter, null));
    MyRelativeLayout.Children.Add(TimeLabel,
        Constraint.RelativeToParent((parent) => { return parent.Width - 20 - TimeLabel.Width; }),
        Constraint.Constant(20));

Any ideas what I could do to fix it?


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>