[英]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.