i created new folder solution explorer of project. want add application wpf windows inside it. cant access classes mainwindow.cs file. purpose making things tidy , clean in project.
questions:
1- how add new wpf window folder , refrence in visual studio 2015?
2- possible change current directory of wpf window added before?
thanks in advance!
without more details, including more precise problem statement "i cant access classes mainwindow.cs file", it's impossible know sure you're doing wrong. having problems namespace.
your c# project has default namespace, can see in project settings under "application" tab. set same name project.
if add folder project in solution explorer in visual studio, new types put folder have folder name included in namespace. example, if start project named "mywpfproject" , nothing else, default namespace "mywpfproject". if add folder named "subfolder", new code module added folder (and folder) have namespace code in module set not project's default of "mywpfproject", more specific namespace "mywpfproject.subfolder".
similarly, if want use types declared in code module added folder, you'll need make sure use correct namespace type. example, add using mywpfproject.subfolder;
top of c# file wants use type, or xmlns:subfolder="clr-namespace:mywpfproject.subfolder
xaml file want use type.
so, in mind, specific questions were:
1- how add new wpf window folder , refrence in visual studio 2015?
see above. can, example, right-click on folder , choose "add/window..." pop-up menu. implement window
object usual. want use it, make sure use correct namespace access new type, , in particular make sure include folder name part of namespace you're using.
2- possible change current directory of wpf window added before?
you can drag , drop files within project like. move them on file system well, i.e. changing directory file stored according new location within project.
in second scenario, important keep in mind visual studio will not change namespace existing code. if start window class directly under project in visual studio, , drag file folder you've created, window class continue in top-level namespace project.
if going rearrange existing project code, grouping modules in folders dragging files there, should consider editing files after you've moved them namespace matches location in project. doing ensure consistent layout not files, type names well.
Comments
Post a Comment