Reputation:
I'm using a shared library to share some of my code. Is it possible to share the xaml.cs files for XAML page templates in the same way by putting them into the shared library?
Upvotes: 1
Views: 94
Reputation: 6091
You can extend UserControl
and reuse that class in your xaml.cs files:
public class MyBaseControl : UserControl
{
// shared functionality
}
and your XAML files look like this:
<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>
and your xaml.cs files:
public sealed partial class CoolUserControl : MyBaseControl
{
public CoolUserControl()
{
InitializeComponent();
}
}
Upvotes: 3