0

Windows Phone 7 アプリケーションの以下のサンプル コードがあり、それを開始点として VB.Net に変換しようとしています。割り当ては次のようになります。

Loaded += (_, __) => { anonymousMethodBody();}

C# から VB への変換ツールを使用すると、変換に失敗します。それらはどのように翻訳されるべきですか?

public MainPage()
{
    InitializeComponent();

    Loaded += (_, __) =>
        {
            PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled;
            cam = new VideoCamera();
            cam.Initialized += (___, ____) =>
                {
                    cam.LampEnabled = true;
                    cam.StartRecording();
                };
            vCam.SetSource(cam);

            new Thread(() =>
                {
                    try
                    {
                        var isf = IsolatedStorageFile.GetUserStoreForApplication();

                        var files = isf.GetFileNames();
                        foreach (var file in files)
                        {
                            Debug.WriteLine("Deleting... " + file);
                            isf.DeleteFile(file);
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine("Error cleaning up isolated storage: " + ex);
                    }
                }).Start();
        };
}
4

1 に答える 1

3

イベント ハンドラーは、Loaded投稿した C# コードでラムダ式を使用して定義されています。ほとんどの VB.NET-C# コンバーターは比較的新しいため、これらをうまく処理できないと思います。これを試して:

AddHandler Loaded, Sub() 'Pass the Loaded event parameters, I cannot see them in your code
                  'The code inside the big block
                   End Sub

電話する必要はありませんRemoveHandler(以下のコメントをお読みください)。

于 2012-04-16T17:01:00.797 に答える