-
May 5th, 2022, 02:57 AM
#1
Thread Starter
Addicted Member
wpf comboboxes causeing null reference crash when visibility or width used in code
I filled a combobox in codebehind and it works correctly. I also set its visibilty to visibility.collapsed in the same function without problem.
when I try to set it to visibility.collapsed later (checkbox checked event) I crash saying something is null. Same thing if I try to set isenabled or anything else. I would think it was a scope problem but it is declared in wpf so it should be available to all code in the codebehind right? If that was the problem then I shouldn't have been able to populated the list from codebehind either as far as I know.
Any thoughts?
-
May 5th, 2022, 03:22 AM
#2
Re: wpf comboboxes causeing null reference crash when visibility or width used in cod
Originally Posted by pmeloy
I crash saying something is null.
The first thing to do is work out what is null. That's what you have a debugger for. Once you know what is null, then you can work backwards to work out why.
-
May 5th, 2022, 03:34 AM
#3
Thread Starter
Addicted Member
Re: wpf comboboxes causeing null reference crash when visibility or width used in cod
No idea what is null. The exception shows up at the title of the wpf page
Code:
<Window x:Class="AdminProfitLoss"
BUT, you twigged a thought so I added a "loading" variable that is true at startup and false after the loading is complete and ignored any settings while it is true. Now it works fine!
I guess it was a case of the combobox not being created before the form_load was being run. I had thought the WPF code was loaded first but I guess not
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|