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

Update ConverterFilterKind enum to be flags #1252

Closed
wants to merge 2 commits into from

Conversation

kaiguo
Copy link
Contributor

@kaiguo kaiguo commented Aug 30, 2019

Idea comes from this API review comment https://github.com/microsoft/microsoft-ui-xaml-specs/pull/48/files#r317833889.

ConverterFilterKind is now a flag, that enables us to combine values like below

<CornerRadiusFilterConverter Filter="TopLeft,BottomRight" />

@kaiguo kaiguo requested a review from jevansaks August 30, 2019 23:35
@kaiguo kaiguo requested a review from a team as a code owner August 30, 2019 23:35
Left = TopLeft | BottomLeft,
Bottom = BottomLeft | BottomRight,
Right = TopRight | BottomRight,
ValueOnly = 0x0010,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of ValueOnly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to work around the CX binding bug we saw in the email thread. See #1239.

Copy link
Member

@jevansaks jevansaks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@kaiguo kaiguo added auto merge This PR will be merged once all checks pass and removed auto merge This PR will be merged once all checks pass labels Aug 31, 2019
@kaiguo
Copy link
Contributor Author

kaiguo commented Aug 31, 2019

@jevansaks Looks like CX doesn't support value combinations like Filter="TopLeft,ValueOnly"

Here's the generated code in metadata provider, fromString value is the raw string "TopLeft,ValueOnly", it throws an invalid arg exception. I guess I'll just close this PR and use our existing code?

    XamlMetadataProvider::RegisterXamlType(
        /* Arg1 TypeName */ 
        L"Microsoft.UI.Xaml.Controls.Primitives.CornerRadiusFilterKind",
        /* Arg2 CreateXamlTypeCallback */ 
        []()
        {
            auto xamlType = winrt::make<EnumXamlType>(
                /* Arg 1 - TypeName */ 
                (PCWSTR)L"Microsoft.UI.Xaml.Controls.Primitives.CornerRadiusFilterKind",
                /* Arg 2 - CreateFromString func */ 
                (std::function<winrt::IInspectable(hstring)>)[](hstring fromString)
                {
                    if (fromString == L"None") return box_value(winrt::CornerRadiusFilterKind::None);
                    if (fromString == L"TopLeft") return box_value(winrt::CornerRadiusFilterKind::TopLeft);
                    if (fromString == L"TopRight") return box_value(winrt::CornerRadiusFilterKind::TopRight);
                    if (fromString == L"BottomLeft") return box_value(winrt::CornerRadiusFilterKind::BottomLeft);
                    if (fromString == L"BottomRight") return box_value(winrt::CornerRadiusFilterKind::BottomRight);
                    if (fromString == L"Top") return box_value(winrt::CornerRadiusFilterKind::Top);
                    if (fromString == L"Left") return box_value(winrt::CornerRadiusFilterKind::Left);
                    if (fromString == L"Bottom") return box_value(winrt::CornerRadiusFilterKind::Bottom);
                    if (fromString == L"Right") return box_value(winrt::CornerRadiusFilterKind::Right);
                    if (fromString == L"ValueOnly") return box_value(winrt::CornerRadiusFilterKind::ValueOnly);
                    throw winrt::hresult_invalid_argument();
                });

            return xamlType;
        });

@jevansaks
Copy link
Member

Oh, shucks. Yeah let's go with what's in master for this release. Can you file a bug on markup, then circle back on the spec review and say we can't do this because of that bug?

@kaiguo
Copy link
Contributor Author

kaiguo commented Aug 31, 2019

Oh, shucks. Yeah let's go with what's in master for this release. Can you file a bug on markup, then circle back on the spec review and say we can't do this because of that bug?

Yeah, will do.

@kaiguo kaiguo closed this Aug 31, 2019
@kaiguo kaiguo deleted the user/kaiguo/converter-updates branch August 31, 2019 02:24
@kaiguo kaiguo restored the user/kaiguo/converter-updates branch September 6, 2019 20:48
@anawishnoff anawishnoff deleted the user/kaiguo/converter-updates branch November 3, 2020 19:55
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

Successfully merging this pull request may close these issues.

None yet

3 participants