-
May 24th, 2022, 05:23 AM
#1
Thread Starter
Addicted Member
vs2017 Wait for WPF to finish?
I often run into problems with null exceptions in code because the WPF controls I refer to don't exist yet.
Is there a way to idle code until WPF has finished rendering?
-
May 24th, 2022, 05:57 AM
#2
Re: vs2017 Wait for WPF to finish?
Can you be more specific? That a control hasn't been rendered doesn't mean that it doesn't exist.
-
May 24th, 2022, 06:34 AM
#3
Thread Starter
Addicted Member
Re: vs2017 Wait for WPF to finish?
I try to set .isenabled and end up with a WPF page showing with a null reference exception. If the button existed it would simple enable or disable it
-
May 24th, 2022, 08:08 AM
#4
Re: vs2017 Wait for WPF to finish?
Again, the fact that something is not rendered does not mean that it does not exist so your problem is almost certainly not that something is not rendered. If you're not prepared to provide a full and explanation of the problem then I'll waste no further time here.
-
May 24th, 2022, 04:38 PM
#5
Thread Starter
Addicted Member
Re: vs2017 Wait for WPF to finish?
There isn't much to explain. I have this button
Code:
<Button x:Name="btnAdd" Content="Add" Grid.Row="1" Grid.Column="2" IsEnabled="False"/>
Then in a combobox event I call this sub and I try to set it enabled or disabled
Code:
Private Sub EnableAdd()
If loading = False Then
If tbxName.Text <> "" And tbxServing.Text <> "" Then
btnAdd.IsEnabled = True
Else
btnAdd.IsEnabled = False
End If
End If
End Sub
When I open the form it immediately says an object is not set to an instance of an object. If I comment out the isenabled lines it loads fine
-
May 24th, 2022, 04:45 PM
#6
Thread Starter
Addicted Member
Re: vs2017 Wait for WPF to finish?
Well I removed the call to that from a combobox textchanged event and it works fine. I guess loading the combobox triggers it too early. I don't really need the combobox event so I will just leave it this way.
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
|