WPF应用程序在Windows 10上看起来有所不同

时间:2019-06-18 10:05:41

标签: c# wpf windows-7 listbox windows-10

我创建了一个WPF应用程序,其中包含一个列表框,其中包含适用于Windows7的复选框(checklistbox)。我在Windows 10上安装了相同的应用程序,并且GUI看起来非常不同。在 Windows 7 上,同一行中的复选框。但是在 Windows 10 上,较高,而文本则较低(请参见图片)

enter image description here

<ListBox x:Name="lbSchlagwoerter" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MinWidth="300" MaxHeight="390" Grid.Row="1" Grid.RowSpan="3" Grid.Column="3" Margin="5,5,5,5">
        <ListBox.Resources>
            <Style TargetType="ListBoxItem">
                <Setter Property="OverridesDefaultStyle" Value="true" />
                <Setter Property="SnapsToDevicePixels" Value="true" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ListBoxItem">
                            <CheckBox Margin="5,2" IsChecked="{TemplateBinding IsSelected}">
                                <ContentPresenter />
                            </CheckBox>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ListBox.Resources>
    </ListBox>[enter image description here][1]

1 个答案:

答案 0 :(得分:1)

您可以将VerticalContentAlignment设置为Center。

import pandas as pd import datetime as dt import smtplib import codecs from IPython.display import HTML def sendEmail(): sender = 'DanielScript@domain.com' receivers = ['daniel@domain.com'] message = """From: Daniel's Script <DanielScript@domain.com> To: Anyone who forgot Subject: New Employees Reminder Hi, here is a list of the people who will start working here soon: \n**{}** \n\nYou're welcome\nDaniel Beiin """.format(df) try: smtpObj = smtplib.SMTP('smtpserver') smtpObj.sendmail(sender , receivers, message) print("Successfully sent email") except SMTPException: print ("Error: unable to send email") df = pd.read_csv(r'testcsv.csv') df.to_html('filename.html') f = codecs.open("filename.html",'r') df = HTML(f.read()) sendEmail()