2014-10-02 7 views
0

WPF8 메시지 박스 :이 코드 구현하기 위해 노력하고있어

Dim result As MessageBoxResult = _ 
MessageBox.Show("Would you like to see the simple version?", _ 
"MessageBox Example", MessageBoxButton.OKCancel) 

If (result = MessageBoxResult.OK) Then 
    MessageBox.Show("No caption, one button.") 
End If 

을하지만 오류가 점점 : 유형 'MessageBoxResult'무슨 일이 일어나고 왜 정의되지 않습니다?

내가 사용하지 않는거야 : 마이크로 소프트 비주얼 스튜디오 프로페셔널 2013 버전 코드 문제 12.0.30501.00 업데이트 2의 Microsoft .NET Framework 버전 4.5.51641

+0

내가 편집 한 제목을 사용할 수 있습니다. "[제목에"태그 "가 포함되어 있어야합니까?] (http://meta.stackexchange.com/questions/19190/)"합의가 "아니오, 그렇지 않아야합니다"로 표시되어야합니다. –

+0

나는 당신이 맞다 –

답변

0

System.Windows가 해결되지 않은 경우 Windows Phone Silverlight 응용 프로그램 (8.0 또는 8.1) 대신 Windows Phone 런타임 응용 프로그램 (Windows Phone 8.1 대상)이 있습니다. Chubosaurus의 단계는 Silverlight 응용 프로그램을 만듭니다.

솔루션 탐색기에서 프로젝트 대상을 확인할 수 있습니다. System.Windows와 MessageBox를 사용하려면 Windows Phone Silverlight 응용 프로그램이 필요합니다. 당신은 윈도우 폰 8.1 응용 프로그램이있는 경우

Windows Phone Silverlight 8Windows Phone Silverlight 8.1

당신은 Windows.UI.Popups.MessageDialog 대신 enter image description here

Async Function ShowMyDialog() As Task(Of Boolean) 
    Dim result As Boolean = False 
    Dim dialog As New Windows.UI.Popups.MessageDialog("Would you like to see the simple version?", "MessageDialog Example") 
    dialog.Commands.Add(New Windows.UI.Popups.UICommand("Ok", 
     Async Sub(command) 
      result = True 
      Dim okDialog As New Windows.UI.Popups.MessageDialog("No caption, one button.") 
      Await okDialog.ShowAsync() 
     End Sub)) 
    dialog.Commands.Add(New Windows.UI.Popups.UICommand("Cancel")) 
    dialog.DefaultCommandIndex = 0 
    dialog.CancelCommandIndex = 1 
    Await dialog.ShowAsync() 
    Return result 
End Function 
+0

당신 덕분에. 실버 라이트 버전이 없다면, 맞습니다! 제공 한 코드 예제를 사용하면 솔루션을 사용할 수 없습니다. 또 다시 당신 덕분에! –

1

아무것도. 작동해야합니다 (직접 구현했습니다). 그래서 그것은 몇 가지 링크 오류/설치 오류/또는 프로젝트 생성 오류가 있어야합니다.

그래서 수정을 할 수 있습니다, 그래서이 시도 할 수 있습니다 :

  • 파일을 -> 새로 만들기 -> 프로젝트
  • 템플릿 선택 -> Visual Basic에서 -> 스토어 앱 -> 윈도우 폰 앱 -> 빈 응용 프로그램 (윈도우 전화 실버) 대상으로
  • 선택 8.0

그것은 당신에게 빈 응용 프로그램을 생성해야

, 다음 t을 할 수 있습니다 스피와 페이지로드 이벤트

Imports System 
Imports System.Threading 
Imports System.Windows.Controls 
Imports Microsoft.Phone.Controls 
Imports Microsoft.Phone.Shell 
Imports System.Windows 

Partial Public Class MainPage 
    Inherits PhoneApplicationPage 

    ' Constructor 
    Public Sub New() 
     InitializeComponent() 

     SupportedOrientations = SupportedPageOrientation.Portrait Or SupportedPageOrientation.Landscape 

    End Sub 

    Private Sub PhoneApplicationPage_Loaded(sender As Object, e As RoutedEventArgs) 
     Dim result As MessageBoxResult = _ 
     MessageBox.Show("Would you like to see the simple version?", _ 
     "MessageBox Example", MessageBoxButton.OKCancel) 

     If (result = MessageBoxResult.OK) Then 
     ' Do whatever 
     End If 

    End Sub 
End Class 

에 메시지 박스를 만드는 것이 우리가 System.Windows가

  • 를 가져옵니다 있는지 확인해야 다음 작동하지 않으면 프로젝트를 마우스 오른쪽 클릭 - 참고 문헌에> 속성
  • 클릭
  • 확실 System.Windows 확인은 확인 표시가
+0

당신이 맞다 고 본다 : ** System.Windows **는 검사되지 않았다 ... 나는 그것을, 그러나 결과, 아직도 동일한 과실 검사한다. 그러나 새로운 프로젝트를 만들려고 할 때 - 모든 것이 잘 작동합니다. 신비주의 ... –

관련 문제