× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Why am I getting an exception on my dependency property?

Gayot Fow
Feb 05, 2015
<p>Changing this line of Xaml... &lt; Setter Property="Style" Value="Transparent"/&gt;</p> <p>To this...</p> <pre><code>&lt;!-- &lt;Setter Property="Style" Value="Transparent"/&gt; --&gt; </code></pre> <p>(i.e., comment it out)</p> <p>Will avoid the exception. </p> <p>Setting a style the way you are doing would entail referencing something already defined in the object tree like {StaticResource Transparent}. </p> <p>The inner exception is 'object reference not set...', which makes it clear that the constructor cannot find a reference to "Transparent" the way it has been coded. Note that the exception is thrown <em>after</em> the TransparentTb is already constructed. You can prove this by setting breakpoints.</p> <p>Also, I checked your TransparentTb code, and it works fine. The culprit is your TabItem Style Setter.</p> <p>This tip was originally posted on <a href="http://stackoverflow.com/questions/8438747/Why%20am%20I%20getting%20an%20exception%20on%20my%20dependency%20property?/8439899">Stack Overflow</a>.</p>
comments powered by Disqus