Skip to main content
 首页 » 编程设计

c#之wpf 如何知道设置 Content 属性

2024年02月05日11zhenyulu

所以如果我在 XAML 中创建一个按钮,

<Button /> 

我可以通过几种方式之一设置内容

<Button Content="My Content" /> 
 
<Button> 
    My Content 
</Button> 
 
<Button> 
   <Button.Content> 
         My Content 
   </Button.Content> 
</Button> 

等等...

我的问题是,当用户以这种方式传递内容时

<Button> 
    My Content 
</Button> 

wpf 如何知道分配 Content 依赖属性?这是我想构建到我的控件中的非常巧妙的功能。

请您参考如下方法: