使.NET内部具有XAML文件 [英] Make 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
?
推荐答案
如果您更改XAML文件的可见性,则需要在XAML文件的UserControl标记中添加 x:ClassModifier ="internal"
.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)需要与代码隐藏文件(例如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.
这篇关于使.NET内部具有XAML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!