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

Binding does not work in winrt c++ desktop #4848

Closed
shelllet opened this issue Apr 18, 2021 · 2 comments
Closed

Binding does not work in winrt c++ desktop #4848

shelllet opened this issue Apr 18, 2021 · 2 comments
Labels

Comments

@shelllet
Copy link

Binding does not work in winrt c++ desktop

binding code in cpp.

 {
    Binding biding2;

    dynamic2 = winrt::make<implementation::Dynamic>(L"100");
    biding2.Converter(dynamic2);
    biding2.Mode(Data::BindingMode::TwoWay);


    biding2.UpdateSourceTrigger(Data::UpdateSourceTrigger::PropertyChanged);

    biding2.Source(dynamic2);
    biding2.Path(PropertyPath(L"Value"));
    Hd().SetBinding(Hd().TextProperty(), biding2);
}

idl defined in used component.

import "Dynamic.idl";

namespace App1
{
    [default_interface]
    runtimeclass MainWindow : Microsoft.UI.Xaml.Window
    {
        MainWindow();
        //Dynamic MyProperty;
    }
}

if I add Dynamic property in MainWindow idl file , this works fine. otherwise if I comment Dynamic property, the binding will don't work. maybe biding2.Path(PropertyPath(L"Value")); has inernal bug. and if i remove binding path set, it's also works fine.

Test code: https://github.com/shelllet/App1

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Apr 18, 2021
@StephenLPeters
Copy link
Contributor

@chrisglein and @MikeHillberg FYI

@chrisglein
Copy link
Member

Believe it is expected that bindings require the metadata to be in the WinMD file to work, which is why this works if you include it in the IDL but not if you don't. If you're using C#, all that's going to happen without having to manage an IDL file. @MikeHillberg and @Scottj1s to confirm.

Assuming so, this is effectively by design for C++ (type metadata is a requirement for binding).

@ghost ghost removed the needs-triage Issue needs to be triaged by the area owners label Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants