代码之家  ›  专栏  ›  技术社区  ›  Roman Starkov

如何构建系统。窗户。MessageBox按钮是否已设置样式?

  •  4
  • Roman Starkov  · 技术社区  · 16 年前

    我正在使用系统。窗户。WPF应用程序中的MessageBox,出于某种原因,其按钮的样式采用Windows 2000的方式——不是WinXP,不是Aero,也不是WPF的默认样式。只有灰色和基本的3d边框。

    1 回复  |  直到 14 年前
        1
  •  7
  •   CyberMonk    16 年前

    Why am I Getting Old Style File Dialogs and Message Boxes with WPF

    基本上,您必须将一个名为“manifest”的XML文件添加到您的应用程序中。

    更新:

    就在台词之后:

    </trustInfo>
    

    粘贴到以下依赖关系部分:

      <!-- Activate Windows Common Controls v6 usage (XP and Vista): -->
      <dependency>
        <dependentAssembly>
          <assemblyIdentity
              type="win32"
              name="Microsoft.Windows.Common-Controls"
              version="6.0.0.0"
              processorArchitecture="*"
              publicKeyToken="6595b64144ccf1df"
              language="*"
            />
        </dependentAssembly>
      </dependency>
    

    我的完整清单如下:

    <?xml version="1.0" encoding="utf-8"?>
    <asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
      <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
        <security>
          <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
            <!-- UAC Manifest Options
                If you want to change the Windows User Account Control level replace the 
                requestedExecutionLevel node with one of the following.
    
            <requestedExecutionLevel  level="asInvoker" uiAccess="false" />
            <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
            <requestedExecutionLevel  level="highestAvailable" uiAccess="false" />
    
                If you want to utilize File and Registry Virtualization for backward 
                compatibility then delete the requestedExecutionLevel node.
            -->
            <requestedExecutionLevel level="asInvoker" uiAccess="false" />
          </requestedPrivileges>
        </security>
      </trustInfo>
      <!-- Activate Windows Common Controls v6 usage (XP, Vista, Win 7) to support themed dialogs: -->
      <dependency>
        <dependentAssembly>
          <assemblyIdentity
              type="win32"
              name="Microsoft.Windows.Common-Controls"
              version="6.0.0.0"
              processorArchitecture="*"
              publicKeyToken="6595b64144ccf1df"
              language="*"
            />
        </dependentAssembly>
      </dependency>
    </asmv1:assembly>
    

    推荐文章