Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
.NET
.NET Core
.NET MAUI
.NET Standard
Active Directory
ADO.NET
Agile Development
AI
AJAX
AlbertAGPT
Alchemy
Alexa Skills
Algorand
Algorithms in C#
Android
Angular
ArcObject
ASP.NET
ASP.NET Core
Augmented Reality
Avalanche
AWS
Azure
Backbonejs
Big Data
BizTalk Server
Blazor
Blockchain
Bootstrap
Bot Framework
Business
Business Intelligence(BI)
C#
C# Corner
C# Strings
C, C++, MFC
Career Advice
Careers and Jobs
Chapters
ChatGPT
Cloud
Coding Best Practices
Cognitive Services
COM Interop
Compact Framework
Copilot
Cortana Development
Cosmos DB
Cryptocurrency
Cryptography
Crystal Reports
CSS
Current Affairs
Custom Controls
Cyber Security
Data Mining
Data Science
Databases & DBA
Databricks
Design Patterns & Practices
DevExpress
DevOps
DirectX
Dynamics CRM
Enterprise Development
Entity Framework
Error Zone
Exception Handling
F#
Files, Directory, IO
Flutter
Games Programming
GDI+
General
Generative AI
GO
Google Cloud
Google Development
Graphics Design
Graphite Studio
Hardware
Hiring and Recruitment
HoloLens
How do I
HTML 5
Infragistics
Internet & Web
Internet of Things
Ionic
Java
Java and .NET
JavaScript
JQuery
JSON
JSP
Knockout
Kotlin
Langchain
Leadership
Learn .NET
Learn iOS Programming
LINQ
Machine Learning
Metaverse
Microsoft 365
Microsoft Fabric
Microsoft Office
Microsoft Phone
Microsoft Teams
Mobile Development
MongoDB
MuleSoft
MySQL
NEAR
NetBeans
Networking
NFT
NoCode LowCode
Node.js
Office Development
OOP/OOD
Open Source
Operating Systems
Oracle
Outsourcing
Philosophy
PHP
Polygon
PostgreSQL
Power Apps
Power Automate
Power BI
Power Pages
Printing in C#
Products
Progress
Progressive Web Apps
Project Management
Public Speaking
Python
Q#
QlikView
Quantum Computing
R
React
React Native
Reports using C#
Robotics & Hardware
RPA
Ruby on Rails
RUST
Salesforce
Security
Servers
ServiceNow
SharePoint
Sharp Economy
SignalR
Smart Devices
Snowflake
Software Architecture/Engineering
Software Testing
Solana
Solidity
Sports
SQL
SQL Server
Startups
Stratis Blockchain
Swift
SyncFusion
Threading
Tools
TypeScript
Unity
UWP
Visual Basic .NET
Visual Studio
Vue.js
WCF
Wearables
Web API
Web Design
Web Development
Web3
Windows
Windows Controls
Windows Forms
Windows PowerShell
Windows Services
Workflow Foundation
WPF
Xamarin
XAML
XML
XNA
XSharp
Register
Login
2
Answers
Styles with Trigger on IsMouseOver still shows the winfows blue color
Anja Simonsen
3y
7.3k
1
Reply
Right now I'm trying to use styles in my very new wpf solution.
I have problems with the Trigger IsMouseOver background color. Even when using another background color it still shows Windows blue on mouse over. Do I have to set another property for the mouse over blue color?
Can anyone tell me, why I can make the style Bold but not cann't change the windows normal blue color on mouseover a button?
I have attached the solution
But here is the code first my app.xaml file
<Application x:Class=
"AnsiBug.App"
xmlns=
"http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x=
"http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local=
"clr-namespace:AnsiBug"
StartupUri=
"MainWindow.xaml"
>
<Application.Resources>
<!--#region Buttons -->
<!--Almindelige knapper-->
<Style TargetType=
"Button"
>
<Setter Property=
"Background"
Value=
"#005b7f"
/>
<Setter Property=
"Foreground"
Value=
"White"
/>
<Setter Property=
"FontFamily"
Value=
"Verdana"
/>
<Setter Property=
"FontSize"
Value=
"12"
/>
<Setter Property=
"Margin"
Value=
"3"
/>
<Setter Property=
"Padding"
Value=
"5 5 5 5"
/>
</Style>
<!--Top Menu knapper-->
<Style TargetType=
"Button"
x:Key=
"TopMenuButton"
>
<Setter Property=
"Background"
Value=
"White"
/>
<Setter Property=
"Foreground"
Value=
"Black"
/>
<Setter Property=
"FontFamily"
Value=
"Verdana"
/>
<Setter Property=
"FontSize"
Value=
"12"
/>
<Setter Property=
"Width"
Value=
"120"
/>
<Setter Property=
"HorizontalAlignment"
Value=
"Left"
/>
<Setter Property=
"HorizontalContentAlignment"
Value=
"Left"
/>
<Setter Property=
"BorderThickness"
Value=
"0"
/>
<Setter Property=
"BorderBrush"
Value=
"Transparent"
/>
<Setter Property=
"Padding"
Value=
"5 0 2 2"
/>
<Style.Triggers>
<Trigger Property=
"IsMouseOver"
Value=
"True"
>
<Setter Property=
"Background"
Value=
"White"
/>
<Setter Property=
"FontWeight"
Value=
"Bold"
/>
</Trigger>
</Style.Triggers>
</Style>
<!--Top SubMenu knapper-->
<Style TargetType=
"Button"
x:Key=
"TopSubMenuButton"
>
<Setter Property=
"Background"
Value=
"#005b7f"
/>
<Setter Property=
"Foreground"
Value=
"White"
/>
<Setter Property=
"FontFamily"
Value=
"Verdana"
/>
<Setter Property=
"FontSize"
Value=
"12"
/>
<Setter Property=
"HorizontalAlignment"
Value=
"Left"
/>
<Setter Property=
"Width"
Value=
"120"
/>
<Setter Property=
"HorizontalContentAlignment"
Value=
"Left"
/>
<Setter Property=
"BorderThickness"
Value=
"0"
/>
<Setter Property=
"BorderBrush"
Value=
"Transparent"
/>
<Setter Property=
"Padding"
Value=
"5 2 2 0"
/>
<Style.Triggers>
<Trigger Property=
"IsMouseOver"
Value=
"True"
>
<Setter Property=
"Background"
Value=
"#005b7f"
/>
<Setter Property=
"FontWeight"
Value=
"Bold"
/>
</Trigger>
</Style.Triggers>
</Style>
<!--#endregion-->
</Application.Resources>
</Application>
And here is my
My MainWindow (the two first images are logos You can put every image you want. The Divider image is included in the solution.
<Window xmlns:syncfusion=
"http://schemas.syncfusion.com/wpf"
x:Name=
"AnsiBug"
x:Class=
"AnsiBug.MainWindow"
xmlns=
"http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x=
"http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d=
"http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc=
"http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local=
"clr-namespace:AnsiBug"
mc:Ignorable=
"d"
Title=
"MainWindow"
Height=
"800"
Width=
"1200"
HorizontalAlignment=
"Center"
VerticalAlignment=
"Center"
WindowStartupLocation=
"CenterScreen"
>
<Window.Resources>
<!--Base Button Style-->
</Window.Resources>
<StackPanel>
<Border BorderBrush=
"Black"
BorderThickness=
"2"
>
<Grid Margin=
"5"
ShowGridLines=
"True"
>
<Grid.ColumnDefinitions>
<ColumnDefinition Width=
"250"
/>
<ColumnDefinition Width=
"*"
/>
<ColumnDefinition Width=
"250"
/>
</Grid.ColumnDefinitions>
<Image Source=
"/Images/Logo/ANSI.gif"
HorizontalAlignment=
"Left"
Width=
"200"
Height=
"80"
Grid.Column=
"0"
Margin=
"0,0,111,125"
/>
<Image Source=
"/Images/Logo/logoBug.gif"
HorizontalAlignment=
"Right"
Width=
"150"
Height=
"80"
Grid.Column=
"2"
Margin=
"158,0,0,149"
/>
<Grid Grid.Column=
"1"
>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width=
"*"
/>
<ColumnDefinition Width=
"*"
/>
<ColumnDefinition Width=
"*"
/>
<ColumnDefinition Width=
"*"
/>
<ColumnDefinition Width=
"*"
/>
<ColumnDefinition Width=
"*"
/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height=
"*"
/>
</Grid.RowDefinitions>
<StackPanel Orientation=
"Vertical"
Grid.Row=
"0"
Grid.Column=
"0"
>
<Button x:Name=
"BtnProjects"
Content=
"Projekter"
Style=
"{StaticResource TopMenuButton}"
/>
<Image Source=
"/Images/TopDivider.jpg"
/>
<StackPanel x:Name=
"ProjectsSubMenu"
>
<Button x:Name=
"BtnDashBoard"
Content=
"Dashboard"
Style=
"{StaticResource TopSubMenuButton}"
/>
<Button x:Name=
"BtnNewBug"
Content=
"Ny fejl"
Style=
"{StaticResource TopSubMenuButton}"
/>
</StackPanel>
</StackPanel>
</Grid>
<!--Række 0 Projekter-->
<!--Række 1-->
<!--Række 2-->
<!--Række 3-->
<!--Række 4-->
<!--Række 5-->
</Grid>
</Grid>
</Border>
<Grid Margin=
"5"
>
<Grid.ColumnDefinitions>
<ColumnDefinition Width=
"*"
/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height=
"*"
/>
</Grid.RowDefinitions>
<TextBlock Text=
"Her kommer anden række"
/>
</Grid>
</StackPanel>
</Window>
Best regards,
Simsen :-)
Attachment:
AnsiBugSolution.zip
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
Data not displaying in listview any help urgent
how to find control by name in wpf