What's the difference between x:Key and x:Name in WPF?

前端 未结 2 1643
梦谈多话
梦谈多话 2020-12-15 02:32

What\'s the difference between x:Key and x:Name in WPF?

I am not sure what the true difference is.

2条回答
  •  死守一世寂寞
    2020-12-15 03:19

    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.

    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.

提交回复
热议问题