Change the Menu Foreground Color in Windows XP does not work. RRS feed

  • Question

  • Hi People! I'm trying to change the foreground color of a Menu object (using templates) but it does not work on Windows XP.

    It works perfectly when I run the same application in Windows Vista. Does anybody knows if is there an workaround for this in Windows XP ? Below is a small piece code that reproduces the problem.

    ========================= BEGIN OF CODE =============================
    	Width="640" Height="480">
    		<LinearGradientBrush x:Key="MenuBackground" EndPoint="0,1" StartPoint="0,0">
    			<GradientStop Color="#F6F6F6" Offset="0.25"/>
    			<GradientStop Color="#EAE8E8" Offset="0.25"/>
    			<GradientStop Color="#DCD9D9" Offset="0.8"/>
    			<GradientStop Color="White" Offset="1"/>
    		<Style x:Key="MenuStyle1" TargetType="{x:Type Menu}">
    			<Setter Property="Background" Value="{StaticResource MenuBackground}"/>
    			<Setter Property="FontFamily" Value="{DynamicResource {x:Static SystemFonts.MenuFontFamilyKey}}"/>
    			<Setter Property="FontSize" Value="{DynamicResource {x:Static SystemFonts.MenuFontSizeKey}}"/>
    			<Setter Property="FontStyle" Value="{DynamicResource {x:Static SystemFonts.MenuFontStyleKey}}"/>
    			<Setter Property="FontWeight" Value="{DynamicResource {x:Static SystemFonts.MenuFontWeightKey}}"/>
    			<Setter Property="Foreground" Value="Red"/> <!-- This line works fine on Vista but not on XP -->
    			<Setter Property="Template">
    					<ControlTemplate TargetType="{x:Type Menu}">
    						<Border SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
    							<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
    	<Grid x:Name="LayoutRoot">
    			<RowDefinition Height="Auto"/>
    			<RowDefinition Height="*"/>
    		<Menu Style="{DynamicResource MenuStyle1}">
    			<MenuItem Header="MenuItem">
    				<MenuItem Header="Item 1"/>
    				<MenuItem Header="Item 2"/>
    				<MenuItem Header="Item 3"/>
    ========================= END OF CODE =============================

    Running this program on Vista, you will have the menu rendered in red as expected, but on XP the menu reders with its default system color.

    Thanks a lot for any help or idea in advance.


    Vista Ultimate SP2
    XP Professional SP3
    NET Framework 3.5 SP1
    Expression Blend 3
    Windows Update and drivers up to date on both systems.
    Wednesday, October 21, 2009 12:55 AM