Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I was doing something very similar with the same result. I had one C# class library that contained a WPF control called UsageControl (xaml with accompanying xaml.cs file). In a separate C# project(i.e. separate dll) I created a C# <strong>class</strong> CPUUsageControl which <strong>inherited</strong> from UsageControl, but put its own spin on it. When I tried to use the CpuUsageControl on one of my views I got the same error you did.</p> <p>What I did to fix that was in my seperate assembly, instead of creating a class that inherited from the base control, i created a new WPF Control that <strong>contained</strong> the base control. I then put all of the logic that was contained in the CpuUsage class into the WpfCpuUsageControl's code behind. I was able to use this object is all of my other controls just fine.</p> <p>For your Control "GridView" i would create a new <strong>WPF user control</strong>, call it GridView and make it <strong>contain</strong> a "ViewBase" as the content of the Grid control.Inside of the ViewBase's content put in your DataGrid, like this:</p> <pre><code>&lt;UserControl....&gt; &lt;Grid&gt; &lt;ViewBase name="vBase"&gt; &lt;DataGrid name="dGrid" /&gt; &lt;/ViewBase&gt; &lt;/Grid&gt; &lt;/UserControl&gt; </code></pre> <p>It is also not apparent to me that you need ViewBase to inherit from UserControl directly. If all you want are for your controls to have certain properties and method why not just make a BaseControl class (that does not inherit from anyone but object) and have future controls inherit from it. Perhaps an abstract base class or interface is what you're after.</p> <p>For MVVM WPF projects, I typically have a BaseViewModel which implements INotifyPropertyChanged for me so I don't have to do that same code everywhere.</p> <p>Best of luck, I know this problem was a huge pain to figure out. The exception message and google are most unhelpful!</p>
 

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