When a component is inside a DataTemplate, it is no longer in the same scope of the page. This is why you can't just access it using an x:Name from the code behind.
The alternatives are:
Use a shared event handler, maybe SizedChanged:
var label = sender
label.MaxLines = value_you _want;
Use x:Static and a static class property:
where the static class would be this:
;] = value_you_want;
You can update the static class property value from anywhere else in the app. For example when the page loads:
MyPage : ContentPage
MyHelperClass.MaxLinesForLabel = value_you_want;
There are other more complicated ways, but those two are the least convoluted and give you easy option to change the value when you need to.
Lance | Technical Support Engineer, Principal
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Telerik Feedback Portal
and vote to affect the priority of the items