Reputation: 71
I have found very little information about this matter. Know that I am a newbie to C# and WPF:
I have a stack panel defined in a XAML file as such :
<StackPanel Orientation="Vertical" >
<TextBlock Text="Locale: " VerticalAlignment="Center"/>
<ComboBox x:Name="comboLocale" Width="60" VerticalAlignment="Center" SelectionChanged="comboLocale_SelectionChanged"/>
</StackPanel>
I want to disable the highlighting that happens when I MouseOver the stack panel, which creates a blue color inside the StackPanel for some reason. I don't have any special style set up yet. Some threads talked about setting OverridesDefaultStyle to TRUE, but this didn't seem to change anything. Also, StackPanel do not have a ControlTemplate available, so most of the solutions I found couldn't be applied since they refer to a Button or TextBlock.
Any input on the matter would be greatly appreciated!
-Regards
Upvotes: 0
Views: 2248
Reputation: 23280
Since you mentioned in a comment you've found out you're actually looking at the expected behavior of a Menu
as your culprit. You'll just need to edit the MenuItem Control Template, more specifically the IsHighlighted
that's causing your highlight. You'd likely find something like this helpful.
Or there's lots more various information found with a quick search for customizing a WPF Menu
/ MenuItem
, hope this helps.
Upvotes: 1
Reputation: 24453
StackPanels
in general have no visual representation and are just layout containers which control placement of other elements. Given that you haven't set anything like Background
on your StackPanel
, it isn't what's causing the highlight you're seeing unless some other part of your XAML or code is modifying it. The behavior you describe sounds like the default behavior of a Button
but without seeing more of your code it's hard to tell where the behavior is coming from.
Upvotes: 2