制作一个XAML文件内部的净 [英] Making a XAML file internal in .Net
问题描述
在我的Silverlight项目,我想就其中包含的.xaml无法从组件外部可见的组件。然而,没有明确的办法,我可以做到这一点。当我修改了.xaml.cs文件的访问修饰符,编译器告诉我:
In my Silverlight project, I would like to make an assembly which contains .xaml that can't be seen from outside of the assembly. However, there is no clear way I can do this. When I modify the access modifier on the .xaml.cs file, the compiler tells me:
Partial declarations of "My xaml class here" have conflicting accessibility modifiers
在XAML文件本身,似乎没有成为一个地方,把我的访问修饰符。总之,我怎么跟我的XAML文件关联的类设置为内部
。
In the xaml file itself, there doesn't seem to be a place to put my access modifier. In short, how do I set the class associated with my xaml file to internal
.
推荐答案
您需要添加一个 X:ClassModifier =内部
XAML文件中的用户控件标记如果您更改的.cs类的可见性文件导入到内部。
You need to add a x:ClassModifier="internal"
in the UserControl tag of the XAML file if you change the visibility of the class in the .cs file to internal.
从XAML文件生成的文件(例如MyControl.g.cs)需要匹配code-隐藏文件(如MyControl.cs)。 X:ClassModifier
您可以控制的部分声明中MyControl.g.cs文件的可见性
The file generated from the XAML file (e.g. MyControl.g.cs) needs to match the code-behind file (e.g. MyControl.cs). x:ClassModifier
allows you to control the visibility of the part declaration in the MyControl.g.cs file.
这篇关于制作一个XAML文件内部的净的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!