So i finally found what caused this issue. Honestly don't know how this happened, because I was sure it worked before.
The issue was cause by having a xaml element (a button in my case) with the attribute x:name
set to just a number / start with a number. Changing it to something like b1
fixed the issue.