I have a project I’ve been working on for quite a while, and I’ve run into a referencing problem. Currently the solution outline looks like this:
Solution
- Agent_Toolbox namespace
- MainWindow
- CallTemplate (UserControl)
- CallTemplate class
- CustomTextBoxes namespace
- NumberTextBox (CustomControl)
- NumberTextBox class
- NumberTextBox (CustomControl)
My problem is that CallTemplate uses one of the NumberTextBox custom controls. I need to reference the CallTemplate class from within the NumberTextBox class in a typeof statement. ie:
ParentControls parentControl = new ParentControls();
Visual parent = parentControl.GetParentControls(this, 3);
if (parent == typeof(CallTemplate))
{
//Do something
}
But no matter what I try I can’t get VS to recognize CallTemplate in this instance as a class. I tried adding a reference to NumberTextBox, but it gives me an error of circular redundancy. I also tried seperating CallTemplate into a separate namespace, but then it can’t find NumberTextBox without a circular redundancy. Ont thing I thought of doing was placing all the User/Custom controls into a separate project within the solution, but then the xaml couldn’t find CustomTextBoxes in order to add the box into the CallTemplate. I’m prertty much frustrated and at a loss, and convinced it’s something simple I’m missing.
Any ideas please?
Edit:
I added a UserControl to the CustomTextBoxes project. VS studio placed it within the same namespace, and generated
public partial class CallTemplate: UserContol
{
public CallTemplate()
{
InitializaComponent();
}
}
If I try to rename the namespace it renames the whole namespace, rather than just this file’s. So I created a new namespace underneath, and pasted the CallTemplate code within it. VS balked at the InitializeComponent() method, saying it doesn’t exist with in the current context. Basically I need to know how to migrate one part of a namespace’s code to a different namespace.
Two projects cannot reference each other. If they did, how would visual studio know which to build first? When that happens, it usually means it’s a design flaw. Combine your projects, or have the references only go one way.