カスタム コード ビハインドを持ち、UserControl から継承する BaseUserControl を作成する必要があるため、実際に使用される UserControl の ParrentClass として使用できます。たくさんの記事を読みましたが、それを機能させることができません。BaseUserControl は、デザイン要素を持つことは想定されていませんが、それを継承する他の UserControls で使用される参照のような純粋にカスタムのものがありますが、デザイン要素は優先されます。このような baseUseControls がさらに必要になるため、Exstensions は問題外です。BaseUsercontrol は 1 つのプロジェクトにあり、それを継承する残りは別のプロジェクトにあります。
1) 継承するクラスだけを作成しようとしました。
public class EntryUserControlBase:UserControl
{
public EntryUserControlBase()
{
}
}
2) UserControl からの継承も
<UserControl x:Class="SPIS_Base.EntryUserControlBase"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
</Grid>
</UserControl>
こんな感じで継承してみました
<local:EntryUserControlBase x:Class="SPIS.AppControls.uclLogin"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SPIS_Base;assembly=SPIS_Base"
mc:Ignorable="d"
d:DesignHeight="200" d:DesignWidth="300">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ShowGridLines="False">
</Grid>
</local:EntryUserControlBase>
その方法を説明している記事をたくさん見つけましたが、実行できません。
任意のヒント?