Vous pouvez modifier ce comportement en obtenant une copie du modèle par défaut du Designer Visual Studio WPF puis dans le commentaire de style ComboBoxReadonlyToggleButton la section ButtonChrome et le remplacer par une bordure. Voici un lien vers le site où j'ai trouvé la solution - http://www.scriptscoop.net/t/d346cf01d844/c-c-wpf-combobox-mouse-over-color.html
Voici mon extrait de code
<Style x:Key="ComboBoxReadonlyToggleButton" TargetType="{x:Type ToggleButton}">
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="IsTabStop" Value="false"/>
<Setter Property="Focusable" Value="false"/>
<Setter Property="ClickMode" Value="Press"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<!-- Replace the ButtonChrome - this eliminated the following
problem: When the mouse was moved over the ComboBox
the color would change to the color defined in ___ but
then would
immediately change to the default Aero blue
gradient background of 2 powder blue colors -
Had to comment out the
below code and replace it as shown
<Themes:ButtonChrome x:Name="Chrome" BorderBrush=" {TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderPressed="{TemplateBinding IsPressed}" SnapsToDevicePixels="true">
<Grid HorizontalAlignment="Right" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}">
<Path x:Name="Arrow" Data="{StaticResource DownArrowGeometry}" Fill="Black" HorizontalAlignment="Center" Margin="3,1,0,0" VerticalAlignment="Center"/>
</Grid>
</Themes:ButtonChrome>-->
<!-- Here is the code to replace the ButtonChrome code -->
<Border x:Name="Chrome" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
<Grid HorizontalAlignment="Right" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}">
<Path x:Name="Arrow" Data="{StaticResource DownArrowGeometry}" Fill="Black" HorizontalAlignment="Center" Margin="3,1,0,0" VerticalAlignment="Center"/>
</Grid>
</Border>
<!-- End of code to replace the Button Chrome -->
J'ai aussi ajouté un code pour changer la couleur d'arrière-plan DarkOrange - Ce code est entré dans le ControlTemplate (dans la section) pour le style de la ComboBox.
<!-- Hover Code - Code that was added to change the ComboBox background
color when the use hovers over it with the mouse -->
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="DarkOrange"></Setter>
</Trigger>
<!-- Hover Code - End -->
Merci, j'avais peur de ça. Je travaille sur la construction de mon modèle maintenant. Le lien Afficher le modèle a été très utile. –
Comment allez-vous changer le modèle, si le problème réside vraiment dans OnRenderMouseOverChanged, plutôt que le modèle? J'ai le même problème, et je ne sais pas comment le résoudre. – skybluecodeflier