Press "Enter" to skip to content


There is some kind of errors, which you can easily fix by edit (or move) only one line of code. My last error is one of them. I don’t remember when I made it, because I can’t recall a birthday of my last line written by hand). Ok, not completely by hand, because I used snippet “propdp”, which are used to generate properties, which we can use from XAML level for example. This snippet before edition looks like this (after double tab):

public int MyProperty
			get { return (int)GetValue(MyPropertyProperty); }
			set { SetValue(MyPropertyProperty, value); }

		// Using a DependencyProperty as the backing store for MyProperty.  This enables animation, styling, binding, etc...
		public static readonly DependencyProperty MyPropertyProperty =
			DependencyProperty.Register("MyProperty", typeof(int), typeof(ownerclass), new PropertyMetadata(0));

I want bool, not int, so I fix one by one and I have sth like this after that:

public bool LoadIt
			get { return (bool)GetValueLoadItProperty); }
			set { SetValue(LoadItProperty, value); }

		//Ten komentarz oczywiście wyrzuciłam bo mi po co
		public static readonly DependencyProperty LoadItProperty =
			DependencyProperty.Register("LoadIt", typeof(bool), typeof(MyWindowClass), new PropertyMetadata(0));

It looks like this.

I press the green triangle, and I’m sure it must work. I don’t do it first time, and … ouch, something is broken.

I have TypeInitializationException from title. My first reaction… no, it must be censored, because children can read it, but when I mastered the world flow composed of the words underlined in red by word application and mastered the wave of self-aggression, I decided that before I use the “search error in stack overflow” function in my VS, I read what says “exception message”.

In general, it has a problem with cast “0” :p Ok, I forgot to change default value. Stupid distracted blonde girl- PropertyMetadata must take false as default value:)

So the last line must look like this:

		public static readonly DependencyProperty CzyMaBycZaladowaneProperty =
			DependencyProperty.Register("CzyMaBycZaladowane", typeof(bool), typeof(MojeOkienko), new PropertyMetadata(false));

And that’s all