Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# WPF partial
I am trying to initiate a class to use it's attributes and method from another class, but the class has 2 constructors(1 with parameters, and one without). the one without parameters it is finding ok, the one with parameters it is not seeing it. it is because it is a partial class?
 
this is the code:
public partial class ScenarioEditorView : UserControl, IScreenSelectorSubItem, IActionable, INotifyPropertyChanged
   {
 
        string p1 = "";
        string fullp = Path.GetFullPath(p1);
        ScenarioEditorViewModel viewModel = new ScenarioEditorViewModel(fullp);
}
fullp is unknown.
 
please help
Posted 27-Jul-11 0:53am
adnama424
Edited 27-Jul-11 0:57am
v2
Comments
s_mon at 27-Jul-11 6:29am
   
Currently, I see none... erh... ok, the default... the one without parameters... is this the complete code?
 
[edit]I'm submitting to fast :)[/edit]
BobJanova at 27-Jul-11 6:34am
   
What is the actual error, and what is the constructor definition of the view model? That code looks okay from a compilation point of view. (It seems kind of backwards to have the view create the view model, but that is a separate discussion.)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Make sure that:
- you didn't forget public for your second constructor
- if the second constructor is in another file (you said your class is partial), then make sure the name of the class is spelled properly, otherwise it will be considered as another class.
 
For now I don't see anything else. Please post more code if you want more help.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

No, it is not because the class is partial: the only thing the "partial" keyword does is letting you split a class (an interface, a struct) among two or more compilation units[^]. This is especially useful when parts of your class are generated by a tool.
 
In other words, keyword "partial" is purely a compile-time construct: once a class is compiled, there are no detectable differences between a partial and a non-partial classes if they are identical in all respects except being partial.
 
The only reason why a compiler could not "see" a declared constructor is because that constructor is not public, and your code is not allowed access to it. Could you post the details of your error, and a code for the constructor's header?
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 195
1 ProgramFOX 130
2 Maciej Los 105
3 Sergey Alexandrovich Kryukov 105
4 Afzaal Ahmad Zeeshan 82
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web01 | 2.8.1411022.1 | Last Updated 27 Jul 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100