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

x:Bind to events support #3172

Closed
1 of 12 tasks
MartinZikmund opened this issue May 16, 2020 · 2 comments · Fixed by #3263
Closed
1 of 12 tasks

x:Bind to events support #3172

MartinZikmund opened this issue May 16, 2020 · 2 comments · Fixed by #3263
Labels
area/code-generation Categorizes an issue or PR as relevant to code generation area/xBind 🪢 Categorizes an issue or PR as relevant to x:Bind kind/enhancement New feature or request

Comments

@MartinZikmund
Copy link
Member

Current behavior

When x:Bind binds to parameterless method in page's code-behind, invalid code is generated.

Expected behavior

Generated code should be valid.

How to reproduce it (as minimally and precisely as possible)

XAML:

<Button Click="{x:Bind OnClick}" />

Code-behind:

private void OnClick()        
{
    System.Diagnostics.Debug.WriteLine("Clicked!");
}

Observe this compiles and works properly on UWP.
In Uno, it generates invalid code:

c0.SetBinding("Click", new Windows.UI.Xaml.Data.Binding{ Mode = BindingMode.OneTime }.Apply(___b =>  /*defaultBindModeOneTime*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, this, ___ctx => OnClick, null )));

Cannot convert method group 'OnClick' to non-delegate type 'object'. Did you intend to invoke the method?

Environment

Nuget Package: latest

Package Version(s): dev

Affected platform(s):

  • iOS
  • Android
  • WebAssembly
  • WebAssembly renderers for Xamarin.Forms
  • macOS
  • Windows
  • Build tasks
  • Solution Templates

Visual Studio:

  • 2017 (version: )
  • 2019 (version: )
  • for Mac (version: )

Relevant plugins:

  • Resharper (version: )

Anything else we need to know?

@MartinZikmund MartinZikmund added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification area/code-generation Categorizes an issue or PR as relevant to code generation and removed triage/untriaged Indicates an issue requires triaging or verification labels May 16, 2020
@jeromelaban jeromelaban changed the title x:Bind to parameterless method does not work x:Bind Event support May 17, 2020
@jeromelaban jeromelaban added kind/enhancement New feature or request area/code-generation Categorizes an issue or PR as relevant to code generation and removed area/code-generation Categorizes an issue or PR as relevant to code generation kind/bug Something isn't working labels May 17, 2020
@jeromelaban
Copy link
Member

Thanks Martin! This is called x:Bind to events. I've got a branch with a PoC to implement that.

@jeromelaban jeromelaban changed the title x:Bind Event support x:Bind to events support May 17, 2020
@jeromelaban jeromelaban added the area/xBind 🪢 Categorizes an issue or PR as relevant to x:Bind label May 17, 2020
@MartinZikmund
Copy link
Member Author

@jeromelaban oh sorry, here I thought I have used it in Uno before 😄 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/code-generation Categorizes an issue or PR as relevant to code generation area/xBind 🪢 Categorizes an issue or PR as relevant to x:Bind kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants