Search code examples
c#wpfxamltablet

WPF brush color changes from win10 to win8 tablet


I have a wpf application developed on windows 10, that i tried now on an x86 windows 8 tablet.

When run in the tablet, some foreground colors show up differently (notably black changes to blue, and white to yellow).

The changes appear on textblocks, labels, button content texts and datagrid headers.

On the other hand, "Red" or any other hex color that's not very dark or very bright will show up as expected.

Then again, i have some Canvas elements there that have fill brushes defined as black or white and they render correctly.

Test case:

<Window Background="#FF808080">
<Grid Margin="10">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <!-- labels -->
    <StackPanel Orientation="Vertical" Grid.Column="0">
        <StackPanel.Resources>
            <Style TargetType="Label">
                <Setter Property="FontSize" Value="30"/>
            </Style>
        </StackPanel.Resources>
        <Label Foreground="Black">Black</Label>
        <Label Foreground="Red">Red</Label>
        <Label Foreground="White">White</Label>
    </StackPanel>
    <!-- graphics -->
    <StackPanel Orientation="Vertical" Grid.Column="1" Margin="10 0 0 0">
        <Ellipse Width="100" Height="100" Fill="Black"/>
        <Ellipse Width="100" Height="100" Fill="Red"/>
        <Ellipse Width="100" Height="100" Fill="White"/>
    </StackPanel>
</Grid>
</Window>

Screenshots from tablet win8 and desktop win10 (in that order): https://i.sstatic.net/EXeKJ.jpg

SOLUTION

Force window to use software rendering with RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;

Now the next question is why GPU accelerated rendering affects text colors, and how to change this specifically. My app is not graphics-heavy so i'll just enable sw rendering for now and be done with this.


Solution

  • Did you check this out, it sounds similar? https://social.msdn.microsoft.com/Forums/silverlight/en-US/05657549-de14-4384-b05d-4bfd7d190cad/wpf-application-show-wrong-textbox-font-color-in-a-windows-81-tablet?forum=wpf