Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eyedropper example #686

Open
ignatvs opened this issue Feb 23, 2023 · 1 comment
Open

Eyedropper example #686

ignatvs opened this issue Feb 23, 2023 · 1 comment

Comments

@ignatvs
Copy link

ignatvs commented Feb 23, 2023

There is something missing in the code examples:

var eyedropper = new Eyedropper();
var color = await eyedropper.Open();

it gives
Error CS4033 The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task'. EyesDrpperApp


Document Details

using Microsoft.Toolkit.Uwp.UI.Controls;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

namespace EyesDrpperApp
{
///


/// An empty page that can be used on its own or navigated to within a Frame.
///

public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
Load();
}

    private void Load() 
    {
        var eyedropper = new Eyedropper();
        var color = await eyedropper.Open();
    }
}

}

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

@michael-hawker
Copy link
Collaborator

@ignatvs as the error message says, you need to make your method async to use the await for the async method on the EyeDropper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants