I really need your help in the subject.

I'm developing a WPF application. In my development machine I'm using Windows 7 with the Aero theme.

I've delivered the application to a colleague that was using Server 2008, without the Aero theme.

Well, the applications look & fell changed dramatically.

The main problem is that I'm not understanding the reason for some behaviors. Let's pick one that should be simply and that should be enough for me to understand the real problem: The Expander!

I'm using a lot of Expanders in a UserControl and I've declare the Expander style has:

<Style TargetType="Expander">
    <Setter Property="Background" Value="#FF9B9B9B" />
    <Setter Property="Padding" Value="0" />
</Style>

That looks great in my machine (Windows 7 with Aero). In my colleague machine the Background value is respected but the toggle button has a gray background border (which seems SystemColors.ControlBrushKey).

This with the Aero enabled, the way I want it: enter image description here

And this what I'm getting with the Classic theme: enter image description here

What am I doing wrong here? What can I do so that my application looks nice in Aero and in Classic?

If I ship the Aero XAML file with my application will it work on a XP machine?

Thanks

有帮助吗?

解决方案

Take a look at this blog post. It seems the author might have been able to solve this problem.

其他提示

Looks like that I've found the problem. I don't quite understand why this has to be like this but.......

The problem was the style definition. It has to be something like:

<Style TargetType="{x:Type Expander}" BasedOn="{StaticResource {x:Type Expander}}">

Therefore, I'll have to analyze all the Styles that I've defined and add the 'BasedOn' property.

Thank you all.

You can force the aero theme for a Window by adding a namespace

xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"

This will work on XP machines as this is built into an assembly shipped with WPF.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top