You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clarify that Page navigation does not guarantee that the DataContext is initialized when the Page is loaded #2629
kind/consumer-experienceCategorizes issue or PR as related to improving the experience of consumerskind/documentationCategorizes an issue or PR as relevant to 3rd party dependencies that are consumed by this projecttriage/untriagedIndicates an issue requires triaging or verification.
would like to add the detail, that for the given case it is not set, we can simply forget to use x:Bind beside Navigation, which needs DI if we want to reach the ViewModel.
On the main uno repo and discord was told to do:
Private MainViewModel? ViewModel => DataContext as MainViewModel;
but as soon as I try to bind a task like this:
no difference if I leave out the Mode, it is throwing a NullReferenceException for the ViewModel! but for things like the simple Title thats not happening at all. Known Issue I heared of would be, twoWay Mode to be complicated, but its the one which is (at least for me) not known to be bugged. So it would be really nice to know how it is working to get the DataContext set in the given case, the navigator fails to do this:
the page can not take the parameter because the routemaps are not enabling this to be done and the second code on the screenshot from the docs are doing what I did replicate.
At this point, I would go so far, out of pure desperation, just for getting this ViewModel for the DataContext, to add:
private MainViewModel? ViewModel => DataContext as MainViewModel ?? this.Navigator()?.Get<MainViewModel>();
Because the x:Bind is applyed at this.InitializeComponent(); if I am correct and seems like the DataContext is not set corrctly as expected. But before you do test it, let me tell you, that is not helping this issue at all, still throwing the same issue at the same line. Hopelessly in my opinion.
So when it comes to performance and functionallity of binding to this kind of things where it would be nice, its just not usable...
To solve this, it would be really nice to know what we CAN do, if this happens, if not even the Navigator can pring us this MainViewModel...
kind/consumer-experienceCategorizes issue or PR as related to improving the experience of consumerskind/documentationCategorizes an issue or PR as relevant to 3rd party dependencies that are consumed by this projecttriage/untriagedIndicates an issue requires triaging or verification.
Activity
ramezgerges commentedon Nov 28, 2024
cc. Nick
DevTKSS commentedon Dec 9, 2024
would like to add the detail, that for the given case it is not set, we can simply forget to use x:Bind beside Navigation, which needs DI if we want to reach the ViewModel.
On the main uno repo and discord was told to do:
or:
but as soon as I try to bind a task like this:

no difference if I leave out the Mode, it is throwing a NullReferenceException for the ViewModel! but for things like the simple Title thats not happening at all. Known Issue I heared of would be, twoWay Mode to be complicated, but its the one which is (at least for me) not known to be bugged. So it would be really nice to know how it is working to get the DataContext set in the given case, the navigator fails to do this:

the page can not take the parameter because the routemaps are not enabling this to be done and the second code on the screenshot from the docs are doing what I did replicate.
At this point, I would go so far, out of pure desperation, just for getting this ViewModel for the DataContext, to add:
Because the x:Bind is applyed at
this.InitializeComponent();if I am correct and seems like the DataContext is not set corrctly as expected. But before you do test it, let me tell you, that is not helping this issue at all, still throwing the same issue at the same line. Hopelessly in my opinion.So when it comes to performance and functionallity of binding to this kind of things where it would be nice, its just not usable...
To solve this, it would be really nice to know what we CAN do, if this happens, if not even the Navigator can pring us this MainViewModel...
DevTKSS commentedon Dec 9, 2024
unoplatform/uno#18710 (comment)
Similar issue also mentioned there, no responses only "not use it"...
DevTKSS commentedon Oct 15, 2025
@ramezgerges at which time then can we officially expect it to be set correctly in our code?