HighlightActiveBrush not changed when color scheme changes

Docking/MDI for WPF Forum

Posted 6 years ago by (Anonymous)
Version: 17.2.0661
Platform: .NET 4.6
Environment: Windows 10 (64-bit)
Avatar

Hello

 

In our application we have a menu item that allows us to change the color scheme. When this is used the brushes used for borders etc. are switched.

That works perfectly for all brushes except the HighlightActiveBrush of the TabControlStyle of the TabbedMdiHost in TabbedMdi-Mode, that keeps the color of the previous color scheme. So basically we have a green line at the top of a tab instead of an orange one after switching from the green to the orange color scheme.

To apply our color scheme we have our own style. Below is a drastically shortened version of that style.

 <Style TargetType="{x:Type docking:TabbedMdiHost}">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="HasTabImages" Value="True" />
        <Setter Property="TabOverflowBehavior" Value="ShrinkWithMenu" />

        <Setter Property="TabControlStyle">
            <Setter.Value>
                <Style TargetType="{x:Type docking:TabbedMdiContainerTabControl}">
                    <Setter Property="HighlightBrushActive" Value="{DynamicResource TabbedMdiActiveTabBackgroundBrush}" />
                    <Setter Property="HighlightBrushInactive" Value="{DynamicResource TabbedMdiInactiveTabBackgroundBrush}" />
                    <Setter Property="TabBackgroundActiveSelected" Value="{DynamicResource TabbedMdiActiveTabBackgroundBrush}" />
                    <Setter Property="TabBorderBrush" Value="{DynamicResource TabbedMdiInactiveTabBackgroundBrush}" />
...
            </Setter.Value>
        </Setter>
</Style>
                   

When the color scheme is changed the DynamicResources change. HighlightBrushActive and HighlightBrushInactive do not react to that change, while the other brushes, like TabBackgroundActiveSelected, are changed correctly.

As far as we could find out HighlightBrushActive is set by TabbedMdiContainerTabControl.UpdateHighlightBrushes. That method is called in AdvanvedTabItem.OnLayoutKindPropertyChanged, if ownerTabControl is not null. It is also called when the Status of the ItemContainerGenerator is changed, but only if requiresPendingHighlightBrushUpdate is true. And in RequestHighlightBrushUpdate, it SelectedTabItem is not null. Finally it is also called in AdvancedTabControl.OnSelectionChanged.

We can gain some insight into that code with a decompiler, but we cannot debug it to see where exactly the HightlightBrushes are either not set or set to the wrong value.

Is this a known problem?

Can we do anything against it, by setting a property in the style? Or is it a bug in the actipro-framework that you can fix?

Comments (13)

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Christian,

Yes, we dynamically set the HighlightBrushActive and HighlightBrushInactive properties based on the selected tab's layout kind.  Any scenario that changes that, such as selected tab change or layout kind change will trigger another update.

When I run our Sample Browser app and switch Metro Light themes to various accented color ones, I see the tabs update their color ok.  Are you able to repro this issue in our sample?


Actipro Software Support

Posted 6 years ago by (Anonymous)
Avatar

Hello,

I cannot reproduce it with your sample. But I noticed one significant difference.

In your sample everything blinks and reappeares when the theme is changed and the tab looses its focus (it is no longer active/selected). So it has to be clicked again to even see the HighlightBushActive.

If I select the TabControl with Snoop, look at the brushes and then switch the theme the colors of all brushes stay the same and I have to select the TabControl again to see the new colors. That seems to indicate that the entire control is replaced with a new one, which would also explain the blinking, the loss of focus and why the color-change works.

 

In our program no such annoying blinking occurs and the tab keeps its focus.

With Snoop I can clearly see that it is the same TabControl and all other brushes are changed, but not the HighlightBrushes.

As soon as I switch to a different tab and back again the HighlightBrushes are also changed.

 

So the problem seems to be that your sample avoids this problem by taking the focus away from the Tab (or creating a completely new one?) and our program does not change the brushes because we keep the tab active.

Do you see any way to update the brush without the annoying blinking and loss of focus?

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Christian,

I tried to repro this in a simple example but even there, we see the visual tree getting reloaded due to the theme change triggering templates to be reapplied, and that causes the blink (and subsequent update of brushes). 

Could you put together a new simple sample that shows what you see so that we can use that to debug with and see what we can do to help?  Please email that to our support address and reference this thread in your email.  Be sure to exclude any bin/obj folders from the ZIP and rename the .zip file extension so it doesn't get spam blocked.  Thanks!


Actipro Software Support

Posted 6 years ago by (Anonymous)
Avatar

Hello,

it will take some time to create a simple sample.

But the problem is exactly the one you descriped. You just recreate the visual tree and reapply all the templates, which obviously will fix all the brushes, but also deselects the currently selected tab so that reselecting it would fix the brushes anyway.

In our program we just update the brush behind the dynamic binding. This not only avoids the blinking but also the loss of the active tab. If we reopen the tab, select a different one and reselect the first one or just reopen the application with the new color scheme, of course everything works again. Your code seems to break the bindings and completely take over setting the Highlight-Brushes, while the bindings of the other brushes survive.

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

We can't really test any changes we make if we can't repro the issue though.  I wouldn't think it would be difficult for you to repro it in a small sample.  But when we tried, the issue didn't show up due to the reload so you must be doing something different.

Without seeing it, the two options I can think of are:

1)  Have some property you'd set on AdvancedTabControl's Style that prevents us from calling the UpdateHighlightBrushes method at all.  That feels a little kludgey but would let you set things externally.

OR

2)  Whenever the BorderBrushPreviewActiveSelected, BorderBrushActiveSelected, or BorderBrushInactiveSelected properties are updated, call the UpdateHighlightBrushes method.  I would think that would trigger the update due to your brush properties updating, but it wouldn't allow external customization.

Thoughts?


Actipro Software Support

Posted 6 years ago by (Anonymous)
Avatar

I'm not saying it is difficult to produce a sample project. It will just take some time, as the colleague actually dealing with this issue is currently busy with other tasks. But he is about to be done with those and will get right onto producing a sample project.

Why do you actually need the UpdateHighlightBrushes method? If it didn't mess with the brushes the binding should work just fine to change same, as it does with all the other brushes.

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Christian,

The method is needed because the highlight bar changes based on focus state and more importantly on the layout kind (normal or preview) of the currently selected tab.  In addition, if any of the tab brushes are gradients, it grabs the last color in the gradient to make a solid color highlight bar brush so that it blends in with the bottom of the tab.  It's assuming any gradient is a vertical one.


Actipro Software Support

Posted 6 years ago by (Anonymous)
Avatar

Hello again,

it has been nearly a week (6 days) since I sent the sample project as required.

I don't expect a solution this quick, but some kind of response would be nice.

Did you get the mail? Did I rename the ZIP-file in a way that it didn't get blocked by your spam-filter? Did someone look at it and understand the problem?

[Modified 6 years ago]

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Christian,

Sorry we never got the support email until a little bit ago when we noticed it had been caught by the Google mail spam filter and never reached our system.  It might have been flagged since you left a couple .dlls in there.

We got it this morning and will take a look.  In the future, we always do our best to reply within a business day (or two max).  If you don't hear a reply from us within that timeframe, it's always good to double check we received the message.  Thanks!


Actipro Software Support

Posted 6 years ago by (Anonymous)
Avatar

OK,

I got an answer now, but it didn't help.

I just sent a little less simple sample, this time leaving out the Actipro-DLLs, which shows the problem a bit better. I hope this time it will get past the spam filter.

 

Thank you

[Modified 6 years ago]

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Christian,

Thanks for the more complex sample.  We got it and were able to add some code to get things working.  If you'd like to try a preview build of what we updated, please write reply to the support ticket and we'll send you a link.


Actipro Software Support

Posted 6 years ago by (Anonymous)
Avatar

We got your preview build and tried it.

It worked in our sample project but not our real code.

We changed our sample project to now, hopefully, get close enough to our real code and I just sent it to your support address. I hope it gets past your spam filter and helps you to find a solution.

 

Thanks

Answer - Posted 6 years ago by (Anonymous)
Avatar

Sorry for the delay,

we tried Release 2017.2 Build 0662 and the problem has been fixed after I sent the last sample project.

 

Thanks

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

Add Comment

Please log in to a validated account to post comments.