Visual Studio Express を使用しているため、WPF カスタム コントロール ライブラリ プロジェクト タイプがありません。snoop を使用すると、スタイルがまったく使用されていないことがわかりますが、スタイルを Window.Resources に配置すると機能します。
私の構造は次のとおりです。
MyApp.Controls
- Themes (Folder)
- generic.xaml (build action "Content", no custom tool)
MyApp
*References MyApp.Controls*
MyApp.Controls.Properties.Assemblyinfo.cs の最後に次のものがあります。
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
generic.xaml コンテンツ:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:MyApp.Controls">
<Style TargetType="{x:Type controls:LogView}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:LogView}">
<TextBlock>Hello!</TextBlock>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
ログ ビュー クラス自体には次のものがあります。
public class LogView : Control
{
static LogView()
{
DefaultStyleKeyProperty.OverrideMetadata(
typeof(LogView),
new FrameworkPropertyMetadata(typeof(LogView)));
}
まだ不足している可能性のあるアイデアはありますか、それとも私が間違ったことをしていますか?