wpf – 如何将Themes / Generic.xaml连接到window1.xaml?
发布时间:2020-12-14 02:52:58 所属栏目:Windows 来源:网络整理
导读:我在Themes / Generic.xaml中有以下按钮样式,我希望它适用于我的 WPF应用程序中的各个按钮. 我如何将它连接到我的window1.xaml? Style TargetType="{x:Type Button}" Setter Property="SnapsToDevicePixels" Value="true"/ Setter Property="OverridesDefau
我在Themes / Generic.xaml中有以下按钮样式,我希望它适用于我的
WPF应用程序中的各个按钮.
我如何将它连接到我的window1.xaml? <Style TargetType="{x:Type Button}"> <Setter Property="SnapsToDevicePixels" Value="true"/> <Setter Property="OverridesDefaultStyle" Value="true"/> <Setter Property="MinHeight" Value="23"/> <Setter Property="MinWidth" Value="75"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Border x:Name="Border" CornerRadius="2" BorderThickness="1" Background="#C0C0C0" BorderBrush="#404040"> <ContentPresenter Margin="2" HorizontalAlignment="Center" VerticalAlignment="Center" RecognizesAccessKey="True"/> </Border> <ControlTemplate.Triggers> <Trigger Property="IsKeyboardFocused" Value="true"> <Setter TargetName="Border" Property="BorderBrush" Value="#202020" /> </Trigger> <Trigger Property="IsDefaulted" Value="true"> <Setter TargetName="Border" Property="BorderBrush" Value="#202020" /> </Trigger> <Trigger Property="IsMouSEOver" Value="true"> <Setter TargetName="Border" Property="Background" Value="#808080" /> </Trigger> <Trigger Property="IsPressed" Value="true"> <Setter TargetName="Border" Property="Background" Value="#E0E0E0" /> <Setter TargetName="Border" Property="BorderBrush" Value="#606060" /> </Trigger> <Trigger Property="IsEnabled" Value="false"> <Setter TargetName="Border" Property="Background" Value="#EEEEEE" /> <Setter TargetName="Border" Property="BorderBrush" Value="#AAAAAA" /> <Setter Property="Foreground" Value="#888888"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> 解决方法
在你的Widow1.xaml(或你的App.xaml,改为)……
<Window1.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="DefaultStyles.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Window1.Resources> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Windows应用程序上的不规则套接字错误(10054)
- wpf – 为什么在Window.Resources项目上设置x:Name不起作用
- 如何在Windows下安装ant contrib?
- windows – 在登录之前如何让bginfo清除现有的壁纸?
- Windows中程序的时间安排
- 利用heat.exe并收集已经本地化的文件名,并使用wix将它们包含
- 如何为Windows应用程序注册自定义键盘快捷方式
- 用户友好的端口敲门器(端口敲门客户端)适用于Windows?
- windows-phone-7 – 一个ListBox里面的WP7 TextBlock没有包
- Windows服务 – 启动Windows服务失败,错误1053