x:Name vs. x:Key --摘自WPFwiki

It depends on where you create your element.

x:Key is only valid in the scope of a ResourceDictionary element. x:Key is used as the primary identifier for elements in the ResourceDictionary. Specifying x:Name is not considered valid (it will cause an exception when accessing resources).

On the other hand, x:Name is valid in the scope of everything but a ResourceDictionary. x:Key is not valid outside the ResourceDictionary scope.

                                                                                  http://www.wpfwiki.com/ 

posted @ 2009-06-11 10:59  keep moving  阅读(562)  评论(2编辑  收藏  举报