Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF custom control XAML null error
    primarykey
    data
    text
    <p>Yet another strange WPF error:</p> <p>I have a custom control in a simple XAML page. The project builds and runs perfectly, with no errors. </p> <p>Here's the XAML:</p> <pre><code>&lt;Window x:Class="Grapher2.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:graph="clr-namespace:Grapher2" Title="Grapher" Width="800" Height="600"&gt; &lt;StackPanel Name="container" Width="700" Height="500"&gt; &lt;graph:GraphCanvas x:Name="graphCanvas" Width="700" Height="500" Background="#ddd" /&gt; &lt;/StackPanel&gt; </code></pre> <p></p> <p>But when I try to view the XAML page in the XAML designer window, I get the message:</p> <blockquote> <p>"Problem Loading--The document contains errors that must be fixed..." </p> </blockquote> <p>When I hit the "Reload the designer" link, an error pops up in the Error List which says:</p> <blockquote> <p>"Object reference not set to an instance of an object" </p> </blockquote> <p>and the line starting with "graph:GraphCanvas..." is underlined.</p> <p>I was originally developing on our development server, and there, everything was the same, except the error was:</p> <blockquote> <p>"Request for the permission of type 'System.Security.Permissions.SecurityPermission (...blah blah... failed.)"</p> </blockquote> <p>Again, everything works perfectly, except that I can't view the page in the XAML designer window, which is keeping me from developing the rest of the app.</p> <p>I've tried cleaning, building, rebuilding, and all combinations of orders of these commands, with no success.</p> <p><strong>EDIT:</strong></p> <p>Please bear in mind this is my first custom control, and I could be doing something horribly, horribly wrong. Like I said, the app compiles and works beautifully, so I'm kinda mystified.</p> <p><strong>EDIT #2:</strong></p> <p>My derived canvas is not a partial class. From my understanding of how <code>InitializeComponent</code> works (<a href="https://stackoverflow.com/questions/245825/what-does-initializecomponent-do-and-how-does-it-work-wpf">What does InitializeComponent() do, and how does it work in WPF?</a>), there is no auto-generated partial class that contains <code>InitializeComponent</code> linked to my control. Again, the control works perfectly without it, except for breaking the XAML design view.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload