당신은 WPF 비주얼 스튜디오 디자이너에서 기본 템플릿의 사본을 얻어서이 동작을 재정의하고 ComboBoxReadonlyToggleButton 스타일의 코멘트 밖으로 ButtonChrome 부분과 테두리로 교체 할 수 있습니다. 여기에 내가 솔루션있는 사이트에 대한 링크입니다 - 여기 http://www.scriptscoop.net/t/d346cf01d844/c-c-wpf-combobox-mouse-over-color.html
내 코드
<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 -->
되고 또한 DarkOrange에 배경색을 변경하는 몇 가지 코드를 추가 - 이 코드는 ControlTemplate에 들어갔다 (섹션에서) 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 -->
감사합니다. 나는 두려웠습니다. 지금 템플릿을 만드는 중입니다. 템플릿 표시 링크는 매우 유용했습니다. –
템플릿이 아닌 OnRenderMouseOverChanged에 문제가 실제로있는 경우 어떻게 템플릿을 변경 하시겠습니까? 나는이 똑같은 문제가 있으며 그것을 고치는 방법에 관해서 나에게 불분명하다. – skybluecodeflier