Reputation: 4125
Why do I get that compile error when I set the constructor this way:
public class Castle
{
public Castle (bool mark, string description)
{
CastleMarked = mark;
CastleDescription = description;
}
bool CastleMarked {get; set;}
string CastleDescription {get; set;}
}
And then initialize it from other place this way:
Castle cas1 = new Castle(true,"Stone");
Upvotes: 0
Views: 8562
Reputation: 8500
Probably because you haven't implemented INotifyPropertyChanged
interface.
And what is this:
CastleMarked {get; set;}
where is type of property?
EDIT:
add public
before class
EDIT2:
Have you checked that or are you only editing your question ;p?
Because this code works fine:
namespace WpfApplication1
{
public class Castle
{
public Castle(bool mark, string description)
{
CastleMarked = mark;
CastleDescription = description;
}
bool CastleMarked { get; set; }
string CastleDescription { get; set; }
}
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
Castle cas1 = new Castle(true, "Stone");
}
}
}
Upvotes: 2
Reputation: 7062
Implement add the methods of the interface. Or remove the Inotifypropertychanged. Also fix the properties like private string property { get; set; }
Upvotes: 0