WPF Getting Control null reference during InitializeComponent

前端 未结 6 2097
-上瘾入骨i
-上瘾入骨i 2021-02-05 10:13

So my InitializeComponent method call in the Window\'s constructor is running through the XML and adding the controls and plugging them into their events.

6条回答
  •  再見小時候
    2021-02-05 10:44

    The Window Control fires Checked events when initializing sub controls that can be checked and are set to checked as initial value.

    I am strongly of the opinion that this is a bug. Just the fact that it fires a NullReferenceException from deep within the MFC assembly should be enough to expect that this is unintended behavior.

    Considering that the Xaml editor creates handler functions within your Control partial class and if this class is not finished being constructed it can't handle events. I don't think firing a checked event for a control your setting as initialized to checked seems right at all.

    I mean, should it fire an Unchecked event if you set it's initial state to unchecked?

提交回复
热议问题