[英]Share xaml.cs files
我正在使用共享库来共享一些代码。 是否可以通过将XAML页面模板的xaml.cs文件放入共享库中来共享它们?
您可以扩展UserControl
并在xaml.cs文件中重用该类:
public class MyBaseControl : UserControl
{
// shared functionality
}
您的XAML文件如下所示:
<local:MyBaseControl x:Class="MyApp.CoolUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyApp">
<Grid>
</Grid>
</local:MyBaseControl>
和您的xaml.cs文件:
public sealed partial class CoolUserControl : MyBaseControl
{
public CoolUserControl()
{
InitializeComponent();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.