ahdaniels
ahdaniels

Reputation: 1060

How come the width of a checkbox in my WPF-application differ between XP and Win7?

I am making a WPF-application.I have a datagrid with a column header that contains a checkbox. I use this checkbox for check/uncheck-all functionality. When I run the application in Win7 it looks normal but on XP the the checkbox is weirdly compressed and does not check when clicked on. Any feedback would be greatly appriciated.

The affected code:

<Grid>
    <DataGrid RowDetailsVisibilityMode="VisibleWhenSelected" SelectionMode="Extended" SelectionUnit="Cell" AutoGenerateColumns="False" IsReadOnly="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserAddRows="False" CanUserDeleteRows="False" Height="Auto" Margin="10,10,10,10" Name="dgSurveyGroups" VerticalAlignment="Top" RowHeight="26" AlternatingRowBackground="Gainsboro" RowHeaderWidth="0" HorizontalAlignment="Left" Width="346">
        <DataGrid.Columns>
            <DataGridTextColumn Binding="{Binding description, Mode=OneWay}" Header="Surveygroup" Width="*"/>
            <DataGridCheckBoxColumn Binding="{Binding Active}" Header="" Width="24">
                <DataGridCheckBoxColumn.HeaderTemplate>
                    <DataTemplate>
                        <CheckBox Name="SuperCheckBox"/>
                    </DataTemplate>
                </DataGridCheckBoxColumn.HeaderTemplate>
            </DataGridCheckBoxColumn>
            <DataGridTemplateColumn Header="Start Date" Width="110">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding startDate, StringFormat=d}"/>
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
                <DataGridTemplateColumn.CellEditingTemplate>
                    <DataTemplate>
                        <DatePicker SelectedDate="{Binding startDate}"/>
                    </DataTemplate>
                </DataGridTemplateColumn.CellEditingTemplate>
            </DataGridTemplateColumn>
            <DataGridTemplateColumn Header="End Date" Width="110">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding endDate, StringFormat=d}"/>
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
                <DataGridTemplateColumn.CellEditingTemplate>
                    <DataTemplate>
                        <DatePicker SelectedDate="{Binding endDate}"/>
                    </DataTemplate>
                </DataGridTemplateColumn.CellEditingTemplate>
            </DataGridTemplateColumn>
        </DataGrid.Columns>
    </DataGrid>
</Grid>

Win7:
enter image description here

WinXP:
enter image description here

Upvotes: 2

Views: 470

Answers (1)

Matěj Z&#225;bsk&#253;
Matěj Z&#225;bsk&#253;

Reputation: 17272

You can force WPF to use the Windows Vista/7 Aero theme in XP. It's one of the fun implications of the fact that WPF reimplements all the system graphical features on its own using its vector graphics.

How to do that.

However be warned, the application will look a bit out of place in Windows XP (with all the modern glassy buttons and so on).

Upvotes: 3

Related Questions