[英]Namespaces in XAML
If I write controls in different namespaces, I can't show the namespaces in XAML. 如果我在不同的名称空间中编写控件,则无法在XAML中显示名称空间。 Example: 例:
Namespace Sample -> Class A
Namespace Sample.Controls -> Class B
We can write in XAML: 我们可以用XAML编写:
...
xmlns:sample="clr-namespace:Sample"
xmlns:controls="clr-namespace:Sample.Controls"
...
<sample:A .../>
<controls:B .../>
But this not: 但这不是:
<sample:Controls.B /> <-- Is not correct! ERROR!
But, when we use expresion blend SDK libraries, yes. 但是,当我们使用expresion blend SDK库时,是的。 They can. 他们能。 They have namespaces and are correct. 它们具有名称空间并且是正确的。 We can use: 我们可以用:
<i:Interaction.Behaviors />
<i:Interaction.Triggers />
<i:DependencyObjectHelper.SelfAndAncestors />
...
Write 'i:' and the intelisense show organization in namespaces... 在名称空间中写入“ i:”,然后显示智能提示组织...
How we can write libraries that do this? 我们如何编写执行此操作的库?
After declaring your name space you have to make an instance of a class from that name space . 声明名称空间后,必须从该名称空间中创建一个类的实例。 so use Windows.ressources. 因此请使用Windows.ressources。
Floww this Link http://www.wpf-tutorial.com/wpf-application/resources/ 流动此链接http://www.wpf-tutorial.com/wpf-application/resources/
With the ILSpy i found the answer. 使用ILSpy,我找到了答案。
In 'i:interaction' the intellisense show an icon of namespace, but is not a real namespace, is an attached property. 在“ i:interaction”中,智能感知显示名称空间的图标,但不是真正的名称空间,是附加属性。 Interaction is a static class, and Behaviors and Triggers are attached properties. 交互是一个静态类,“行为”和“触发器”是附加的属性。
Then, when we write: 然后,当我们写:
<TextBox>
<i:Interaction.Behaviors> // Is a Attached Property, not an object
...
</i:Interaction.Behaviors>
</TextBox>
I thought that the syntax for properties and attached properties was the same, but no... is , not 我以为属性和附加属性的语法是相同的,但是不...是,不是
<TextBox>
<TextBox.Width> // "normal" object property: <object+property>
...
</TextBox.Width>
<i:Interaction.Triggers> // attached property: <attachedProperty>
...
</i:Interaction.Triggers>
</TextBox>
Is correct?!? 是正确的?!?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.