WPF设置全局控件样式

方法:

在资源文件APP.XAML中添加如下资源

<Application x:Class="_360UI.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="/View/StartWindow.xaml">
    <Application.Resources>
         
    	<ResourceDictionary>

            <Style TargetType="{x:Type ScrollBar}" BasedOn="{StaticResource DefaultScrollBar}"></Style>
            <Style TargetType="{x:Type ScrollViewer}" BasedOn="{StaticResource DefaultScrollViewer}"></Style>
            </ResourceDictionary.MergedDictionaries>
    	</ResourceDictionary>
         
    </Application.Resources>
</Application>

其中

 <Style TargetType="{x:Type ScrollBar}" BasedOn="{StaticResource DefaultScrollBar}"></Style>
 <Style TargetType="{x:Type ScrollViewer}" BasedOn="{StaticResource DefaultScrollViewer}"></Style>

部分设置了全局进度条的样式!其他控件设置默认样式类似;

猜你喜欢

转载自blog.csdn.net/u010975589/article/details/70053084