❔ Object reference not sent to an instance of an object
I have a WinUI3 app that uses C# and XAML, i'm attempting to foreach files.
Files looks like this:
(not actual files, just mock data)
But, when I create the NavigationViewItem with code, it gives me
Code:
23 Replies
You got a line for us?
What do you mean?
Like; where it's erroring?
Exactly
I set some breakpoints, it said it's where i'm doing new NavigationViewItem
new NavigationViewItem()
? That's.... interestingyeah
I'd say it is because you run it asynchronously in the Dispatcher
I have to do that, because it won't let me create the nav items
because different thread or whatever
Different thread? You can usually add MenuItems as easy as
let me try that, with out the dispatcher
Okay, but that means you are running the entire function in a different thread.
yeah, when I receive a message from the websocket, it adds the item
that's my intention
if it's possible
Can we see more code? What I'd think is, that the
NavigationViewItem
s should be created in the same thread, where the NavigationView
was created and your socket just passes you the data for itYeah, i'm creating the navigation view in the actual XAML. Not in the code.
https://hastebin.skyra.pw/digojikiya.csharp
had to find a hastebin service to upload the code to. too big for discord
this is nvSample_Loaded_1
Hummm, in that case, passing data will be more difficult. Can you try the same approach with
Dispatcher
as before, but use
holy, it works now tysm!
everything works now, but i'm not sure if you'll be able to help me with another error.
The file contents logs, and the "possibly set value" also logs. But, the monaco script doesn't work. When I manually execute the JS in the devtools console, that appears to work; but the executescriptasync isn't doing anything. I did the task delay to wait for the editor to load once navigation was completed.
Ah, I never worked with MonacoEditor. So I probably cannot help
MonacoEditor, is the WebView2; sorry
Do you have any way to check if the script was executed correctly?
the value doesn't set the contents
Well, I am not sure what the script is referring to altogether. No clue what "monaco.editor.getModels()" is doing 😄. I cant help any further
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.