Style default selected background visual style for DateTimeB

Editors for WPF Forum

Posted 8 years ago by Patrik Cedendahl
Version: 10.2.0533
Avatar
Hello,
This is a simple question about how to change the defaulted (blue at the moment) selected background (SelectionBrush in WPF) for Year, month, day part when tabbing between them. Our customers has problems to see where the cursor are.

//Thanks

[Modified at 01/24/2011 02:43 AM]

Comments (6)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Patrik,

The SystemColors.HighlightBrush is currently used, with an opacity of 0.4. You can change this using an implicit Style for the SelectionLayer element like so:
<Application ...
    xmlns:editors="http://schemas.actiprosoftware.com/winfx/xaml/editors">
    <Application.Resources>
        <Style TargetType="editors:SelectionLayer">
            <Setter Property="SelectionBrush" Value="Red" />
        </Style>
    </Application.Resources>
</Application>
You may want to set the Opacity property also, based on your needs. This has to go into your application resources, otherwise it will not be picked up by the SelectionLayer elements (because they do not derive from Control).


Actipro Software Support

Posted 8 years ago by Patrik Cedendahl
Avatar
I tried this. I added the Style to my APP.XML but still the SelectionBrush is blue. What im doing wrong???
Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Patrik,

I just tried this again and it worked as expected. If you can put together a small sample project that reproduces the issue and email it over to our support address, then we can take a closer look.


Actipro Software Support

Posted 8 years ago by Wilfried Goller
Avatar
Hello,
i have got the same problem with the selectionbrush. i set the property but the selection is still blue. are there any suggestions?
Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Wilfried,

We never receieved a sample project that reproduced this issue and the above code still works in our tests. If you can put together a small sample project that reproduces the issue and email it over to our support address, then we can take a closer look.


Actipro Software Support

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Wilfried,

Thank you for the sample. As stated above:

Quote:
This has to go into your application resources, otherwise it will not be picked up by the SelectionLayer elements (because they do not derive from Control).


If you put it in the window's resources then it will not be picked up.

If an element that does not derive from Control (i.e. TextBlock, SelectionLayer, etc) is in a ControlTemplate, then it will only pick up Implicit Styles that are defined inside the ControlTemplate or in the Application resources. They will not pick up Implicit Styles defined anywhere else, such as a visual higher up the tree.

This is how WPF was designed to prevent implicit Styles from inadverently affecting elements inside controls.


Actipro Software Support

The latest build of this product (v2018.1 build 0675) was released 8 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.