The Header property of the TreeViewItem
is statically typed to be of type object
.
Therefore the ==
yields false
. You can reproduce this with the following simple snippet:
object s1 = "Hallo";
// don't use a string literal to avoid interning
string s2 = new string(new char[] { 'H', 'a', 'l', 'l', 'o' });
bool equals = s1 == s2; // equals is false
equals = string.Equals(s1, s2); // equals is true