locked
Change color for default Mouseover ComboBox RRS feed

  • Question

  • Hi everyone, I have been able to change the popup for the ComboBox, but I still cannot find ways to change the light blue color of actual mouseover of the Combobox (not on the popup).  I couldn't find a mouseover event in ComboBox, was wondering how this can be altered.

     

    Thanks in advance, DJWP

    Monday, April 26, 2010 6:04 PM

Answers

  • Hi Were-Panda,

    I think you want to change the ComboBox color when the mouse over it. you are right to remove RenderMouseOver="{TemplateBinding IsMouseOver}" from the template, and also you should add your trigger for the IsMouseOver property.

     

    Sincerely,

    Bob Bao


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by DJ Were-Panda Thursday, April 29, 2010 9:20 PM
    Wednesday, April 28, 2010 3:24 AM

All replies

  • Hi there,

    sounds like you're refering to the ubiquituous selection colors that - even if you explicitly set them in a style - are being overridden by the system colors. That said, you'd either have to completely override the control's template or override the system colors in your style. Assuming that you don't want to completely replace the template, the latter could easily be achieved by adding (overwriting) the appropriate resources to your style, i.e.:

    <Style.Resources>
      <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Red"/>
      <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Yellow" />
    </Style.Resources>
    
    
    See my answer in this thread for a complete style example. While I haven't ever used this with a ComboBox, I'm pretty sure it would work in just the same way ...

    Cheers,
    Olaf
    http://blogs.intuidev.com
    Monday, April 26, 2010 6:22 PM
  • Hi Olaf, thanks for the quick response.  I tried your suggestion from the other thread, but no avail...still light blue. :(

     

    I think I found what I need to change.  Here is the line from ComboBox:

    <Microsoft_Windows_Themes:ButtonChrome x:Name="Chrome" SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderPressed="{TemplateBinding IsPressed}">
    							<Grid HorizontalAlignment="Right" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}">
    								<Path x:Name="Arrow" Fill="White" HorizontalAlignment="Center" Margin="3,1,0,0" VerticalAlignment="Center" Data="{StaticResource DownArrowGeometry}"/>
    							</Grid>
    						</Microsoft_Windows_Themes:ButtonChrome>

    The element I need to change is:

    RenderMouseOver="{TemplateBinding IsMouseOver}"

    When I remove that, obviously the light blue glow animation goes away.  How do I access the TemplateBinding IsMouseOver palette?  Or is it better to just remove it and not worry about mouse over event?

    The reason I want to change it is because my foreground/text is going to be white, and a light blue background on white text is aesthetically not good.

    Regards, DJWP

    Tuesday, April 27, 2010 7:01 PM
  • Hi DJ,

    ah, now I understand what you mean (I was thinking you were talking about the control's selection colors). While I'm not perfectly sure as to how exactly this works (I've never peeked at the source behind the PF-chromes), the only logic assumption is simply that the TemplateBinding refers to what has been defined in the PresentationFramework.Aero assembly which itself hosts the ButtonChrome. Now if you want to find a definite answer to this, you can use a tool such as Reflector to get behind the curtains. However, I don't think you'll be able to simply override a prop or to in there - you might be better of with just replacing the chrome alltogether (at least that's what I'd do).


    Cheers,
    Olaf
    http://blogs.intuidev.com
    Tuesday, April 27, 2010 8:38 PM
  • Hi Were-Panda,

    I think you want to change the ComboBox color when the mouse over it. you are right to remove RenderMouseOver="{TemplateBinding IsMouseOver}" from the template, and also you should add your trigger for the IsMouseOver property.

     

    Sincerely,

    Bob Bao


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by DJ Were-Panda Thursday, April 29, 2010 9:20 PM
    Wednesday, April 28, 2010 3:24 AM
  • Hi Bob, perfect!  It worked as intended.  Thank you. :)

     

    Just out of curiosity, how difficult will it be to animate that?

    Thursday, April 29, 2010 9:21 PM