创建自定义控件时会有默认主题generic
使用方法:
1、类库中创建扩展类,加上 DefaultStyleKeyProperty.OverrideMetadata
public class SearchTextBox : TextBox
{
static SearchTextBox()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(SearchTextBox), new FrameworkPropertyMetadata(typeof(SearchTextBox)));
}
public SearchTextBox()
{
}
//其它扩展功能....
}
2、类库中创建Themes目录
3、类库中创建Generic.xaml文件
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ShoppingGuide.Controls">
<Style TargetType="{x:Type local:SearchTextBox}">
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="{StaticResource