18
votes

In Windows 8 RTM with VS2012 RTM I noticed my WPF app was giving me deformed radio buttons so I decided to create a sample to see if I was doing something wrong.

Here's the entire XAML App :

<Window x:Class="WpfApplication1.MainWindow" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" SizeToContent="WidthAndHeight">
    <Grid>
        <StackPanel Margin="20">
            <RadioButton Content="Option 1" GroupName="1"/>
            <RadioButton Content="Option 2" GroupName="2"/>
            <RadioButton Content="Option 3" GroupName="3"/>
        </StackPanel>
    </Grid>
</Window>

Here I have the DPI settings set to 100%, which is actually NOT the default in Windows 8 (well at least for my 1920x1200 screen it isn't). You'll see the radio buttons are perfect.

enter image description here

This is the same exact application with DPI settings at 125% which is the default DPI for my screen resolution.

enter image description here

Here's 150%

enter image description here

You can see the inner circles aren't centered within the outer circle and it looks TERRIBLE. System applications with radio buttons are fine - but my WPF 4.5 app is not. Once again this sample app is 100% RTM bits and from scratch under Win 8.

Is it just all broken or is there a way to fix this (apart from insisting people put 100% DPI scaling).

Was really hoping Win8 would have gone a long way for high res screens and scaling issues like this, but something simple is badly broken out of the box :-(


Edit: filed connect bug https://connect.microsoft.com/VisualStudio/feedback/details/758368/radio-button-rendering-is-incorrect-on-windows-8-with-125-dpi-scaling-set

Edit: 8/29/12:

The WPF team has recently reviewed this issue and will not be addressing this issue as at this time the team is focusing on the bugs impacting the highest number of WPF developers. If you believe that this was resolved in error, please reactivate this bug with any necessary supporting details.

2
It's probably not Win8's fault per se - WPF draws all its own controls, although the default themes do go out to the OS for some elements of them to get better integration. This may well be a bug in the (still prerelease) .NET 4.5 version of WPF. Report it to Microsoft and see if they think it's worth fixing (unfortunately they don't always agree with people like us over what's worth fixing).Matthew Walton
I think the OP said he was building all this with the RTM bits. If that's the case it is a bit worrying. I'm just about to repave my dev machine with the RTM of W8 and VS - I hope there aren't more gotchas like this in there.ZombieSheep
@matthew - good reminder that WPF draws its controls. just checked at 125% on Win7 and they're perfectly centered if a little blurry. I'll report it as soon as I find the right place to do so. and as zombiesheep said I'm using RTM and not expecting any updates to this :-/ in a real business app being widely deployed i'd be embarassed to have to ship thisSimon_Weaver
Just for fun, I'm curious if these controls are aligned to 5 pixel boundaries? Developers shouldn't have to worry about that but I remember reading something in WinRT that for DPI scaling performance purposes things should be aligned at multiples of 5px. That's why a WinRT "unit" is 20px for example. Might not apply to WPF at all, but thought I'd just ask for academic purposes.Jared Bienz - MSFT
Shouldn't that be put as the answer rather than as part of the question?N_A

2 Answers

1
votes

Everything in WPF is styled. In the case of the default system styles they sometimes, in my own experience, have little issues like this. A simple fix, to confirm it is the style and not the OS itself is to restyle the control yourself and see if that fixes it.

You can find the original style by looking at this question. These will help you rebuild and / or fix the issue

0
votes

You could try put the stackpanel in a viewbox .. maybe