Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

The name "someName" does not exist in the current context?

$
0
0

Hello. I've created a class that derives from the "Image" control. I've declared this class in my project as:

namespace MyProject.SubNameSpace1
{
     public class MyImageClass : Image
     {
     ...etc...


I then map to this namespace in MainWindow.xaml as follows:

xmlns:SubSpace="clr-namespace:MyProject.SubNameSpace1"

I then add an instance of "MyImageClass" in MainWindow.xaml via:

<SubSpace:MyImageClass Name="mainImage" ... />

I receive no error messages in the XAML and the control appears in the designer. But when I try to access the object via its name in the MainWindow.xaml.cs code-behind file:

using MyProject.SubNameSpace1;

mainImage.DoSomething(...);

I get "The name "mainImage" does not exist in the current context" error at compile time. What am I doing wrong here? Thank you in advance.-L




Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>