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

C++/WinRT - Can't two-way bind primitive types to IInspectable #7986

Open
JaiganeshKumaran opened this issue Dec 3, 2022 · 6 comments
Open
Labels
area-XamlCompiler bug Something isn't working team-Markup Issue for the Markup team

Comments

@JaiganeshKumaran
Copy link
Contributor

JaiganeshKumaran commented Dec 3, 2022

Describe the bug

Can't two-way bind a property of a primitive type to IInspectable because the generated code uses unknown_cast, which doesn't exist, instead of unbox_value.

Steps to reproduce the bug

  1. Create a property of a primitive type in a view model.
  2. Two-way bind it from XAML on a property of type IInspectable (Object).
  3. See error in the generated code.

Expected behavior

Generated code should correctly use unbox_value.

Screenshots

Screenshot 2022-12-03 at 15 50 53

NuGet package version

WinUI 2 - Microsoft.UI.Xaml 2.8.1

Windows version

Windows 11 (21H2): Build 22000

Additional context

Workaround by defining unknown_cast in pch.h:

namespace winrt
{
	template <typename T>
	T unknown_cast(IInspectable const& value)
	{
		return unbox_value<T>(value);
	}
}
@JaiganeshKumaran JaiganeshKumaran added the bug Something isn't working label Dec 3, 2022
@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Dec 3, 2022
@bpulliam bpulliam added product-winui2 team-Markup Issue for the Markup team area-XamlCompiler and removed needs-triage Issue needs to be triaged by the area owners labels Dec 5, 2022
@github-actions
Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 3, 2023
@JaiganeshKumaran
Copy link
Contributor Author

This issue needs to be fixed, as it prevents basic tasks with x:Bind in a C++/WinRT application. Please anyone.

@JaiganeshKumaran
Copy link
Contributor Author

@bpulliam

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Dec 13, 2023
@JaiganeshKumaran
Copy link
Contributor Author

Also, consider allowing C++ developers to contribute to the open-source XAML compiler.

@bpulliam bpulliam reopened this Feb 29, 2024
@bpulliam bpulliam removed needs-triage Issue needs to be triaged by the area owners product-winui2 no-issue-activity labels Feb 29, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Feb 29, 2024
@bpulliam bpulliam removed the needs-triage Issue needs to be triaged by the area owners label Feb 29, 2024
@JesseCol
Copy link

JesseCol commented Mar 1, 2024

Hi, does this repro in WinAppSDK / WinUI3? Or just in WinUI2? Thanks!

@JesseCol JesseCol added the needs-author-feedback Asked author to supply more information. label Mar 1, 2024
@JaiganeshKumaran
Copy link
Contributor Author

@JesseCol Yes, the generated code is still broken in WinUI 3.
Screenshot 2024-03-02 at 10 13 23

@microsoft-github-policy-service microsoft-github-policy-service bot added needs-triage Issue needs to be triaged by the area owners and removed needs-author-feedback Asked author to supply more information. labels Mar 2, 2024
@codendone codendone removed the needs-triage Issue needs to be triaged by the area owners label May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-XamlCompiler bug Something isn't working team-Markup Issue for the Markup team
Projects
None yet
Development

No branches or pull requests

4 participants