Issues with ViewLocator Navigating Views after Publishing #16438
Replies: 1 comment 3 replies
-
Have you double checked that you don't have AOT enabled? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a simple application that essentially accepts directories from the user, after which the user continues onto a new page to perform error checks. In order to navigate views, I am currently using the ViewLocator, and it works perfectly well when I run the application from within Visual Studio.
For reference, this is the relevant portion in MainWindowViewModel.cs:
Here, ContentViewModel is bound to the "Content" property of the Window tag in MainWindow.axaml.
I have a "Continue" button that is bound to the NextCommand command. When run from within Visual Studio, pressing "Continue" changes the view to the "RunCheckView", as one would expect from the ViewLocator. However, after publishing the application, pressing "Continue" does nothing. The application does not crash, and the UI, outside of the "Continue" button, works perfectly fine. It just doesn't navigate to the RunCheckView. As I said earlier, this does not happen when run from within Visual Studio.
I have tried searching this up and saw some people attributed this to trimming, and so I tried the following:
I saw the first entry being used in the Avalonia sample for navigating views, but it didn't work. The other two didn't either. As for how I published it, I just did
dotnet publish MyProject.csproj -r win-x64
.To be clear, I am absolutely sure that the command for switching views is working properly -- the "NextScreen" method in MainWindowViewModel is being called properly (it properly prints debug print statements I inserted). However, changing the ContentViewModel does not change the view itself. Again, this only happens after publishing; this is not an issue when run from within Visual Studio.
If it matters, I am on Windows, but this is set up as a cross-platform application. I'm using NET 8.0 as well.
So, what can I do about this?
Thanks in advance, any help is appreciated.
Beta Was this translation helpful? Give feedback.
All reactions