Accessing controls using C# code behind in Xamarin.Forms
Asked Answered
K

1

6

I can't access a label defined in the xaml file from the code behind C# code.

I tried the x:name="l" property but it tells me that "'l' is not defined":

enter image description here

Could anyone help me how to access controls from C# code behind by providing an example?

Katricekatrina answered 2/6, 2018 at 0:52 Comment(2)
what you're doing is correct, but the XF Intellisense is pretty flaky. Try restarting VS, and do a clean and build to see i that fixes itWallacewallach
@Wallacewallach Thanks unloading and reloading the project really did the trick put this solution for me to mark it as answer thanks againKatricekatrina
W
8

what you're doing is correct, but the XF Intellisense is pretty flaky. Try restarting VS, and do a clean and build to see i that fixes it

Wallacewallach answered 2/6, 2018 at 1:46 Comment(2)
Just restarting VS (VS2017 in my case) sorted this. Who'd have thought eh ?Tay
The problem persists (and your solution to it still works, thank you very much!) in 2022.Gliadin

© 2022 - 2024 — McMap. All rights reserved.