문제

WPF 앱에 System.Windows.MessageBox를 사용하고 있으며 어떤 이유로 버튼은 WPF 기본값이 아닌 Aero가 아닌 Winxp가 아닌 Windows 2000 Ways 스타일입니다. 기본 3D 경계가있는 회색.

더 현대적인 스타일로 어떻게 나타나게 할 수 있습니까? (실제로 어느 쪽이 중요하지 않음)

도움이 되었습니까?

해결책

매니페스트로 이것을 고칠 수 있습니다. 단계별 지침은이 기사를 참조하십시오. WPF를 사용하여 구식 파일 대화 상자와 메시지 상자를 얻는 이유

기본적으로 응용 프로그램에 'Manifest'라는 XML 파일을 추가해야합니다.

업데이트:

실제로 VS2008에서는이 작업을 수행하는 것이 매우 쉽습니다. 프로젝트 속성-> 응용 프로그램으로 이동하여 'UAC 설정보기'버튼을 클릭하십시오. 이렇게하면 응용 프로그램 매니페스트 파일을 자동으로 생성하고 열 수 있습니다. 이 파일을 다음과 같이 편집하십시오.

라인 직후 :

</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>

이 작업을 수행 한 후 앱, 실행 및 푸리를 작성하기 만하면 MessageBox 대화 버튼이 시스템 테마 스타일을 사용합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top