gpt4 book ai didi

c# - 我最近开始自己学习 WPF。声明 Name 与 x :Name? 时有什么区别

转载 作者:太空狗 更新时间:2023-10-29 21:15:42 26 4
gpt4 key购买 nike

例如,我有这段代码:

<Grid>
<Rectangle Name="TheRectangle" Fill="AliceBlue" Height="100" Width="100">
</Rectangle>
</Grid>

对比

<Grid>
<Rectangle x:Name="TheRectangle" Fill="AliceBlue" Height="100" Width="100">
</Rectangle>
</Grid>

非常感谢您提供的信息。我对学习这样的新东西感到非常兴奋。 :D

最佳答案

wpfwiki

There is basically no difference between the two.

The "x:Name" expression is used in XAML to assign a name to an object that will be used to access the object from the code-behind.

Many classes of the framework expose a Name property, which does exactly this. For these classes, both x:Name and the Name property can be used interchangeably.

关于c# - 我最近开始自己学习 WPF。声明 Name 与 x :Name? 时有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1718814/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com