我有一个自定义的(例如称为),其中包含多个子控件。 我想创建一个,其中包含一组样式和依赖属性分配,用于设计目的(没有样式,控件看起来像一堆泥巴)。 以后我会注释这些样式。
问题在于,我不知道如何设置样式的,以指向正在开发的。
以下是示例:
<UserControl.Resources>
<Style TargetType="this">
</Style>
</UserControl.Resources>
<UserControl x:Class="YourProjectName.UserControl1"
xmlns:local="clr-namespace:YourProjectName"
<UserControl.Resources>
<Style TargetType="{x:Type local:UserControl1}">
<Setter Property="Background" Value="Green"></Setter>
</Style>
</UserControl.Resources>
</UserControl>