Skip to content

Conversation

@acoates-ms
Copy link
Contributor

@acoates-ms acoates-ms commented May 28, 2020

There is currently no way to get to the XAML element from a reactTag -- which is something requested by several partners.

This creates a XamlUIService class that can be used to expose XAML specific functionality from a ReactContext. This new class exposes ElementFromReactTag which is the equivalent of the viewForReactTag method exposed on iOS. It also exposes DispatchEvent which is currently on ReactContext directly, but is planned to be deprecated from the current class, as we want ReactContext to be platform agnostic, allowing native modules to be sharable across platforms.

Sample usage based on example in the #4327:

    REACT_METHOD(startBringIntoView);
    void startBringIntoView(int reactTag) noexcept {
        auto uiService = winrt::Microsoft::ReactNative::XamlUIService::FromContext(m_reactContext);
        uiService.ElementFromReactTag(reactTag).as<winrt::UIElement>().StartBringIntoView();
    }

Fixes #4327

Microsoft Reviewers: Open in CodeFlow

@acoates-ms acoates-ms requested a review from a team as a code owner May 28, 2020 15:22
Copy link
Member

@asklar asklar left a comment

Choose a reason for hiding this comment

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

Thanks for making this WinUI 3 friendly :)

Copy link
Member

@vmoroz vmoroz left a comment

Choose a reason for hiding this comment

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

:shipit:

@acoates-ms acoates-ms added the AutoMerge Causes a PR to be automatically merged once all requirements are passed (label drives bot activity) label May 28, 2020
@ghost
Copy link

ghost commented May 28, 2020

Hello @acoates-ms!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

Do note that I've been instructed to only help merge pull requests of this repository that have been opened for at least 10 hours, a condition that will be fulfilled in about 8 hours 30 minutes. No worries though, I will be back when the time is right! 😉

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 2809c9a into microsoft:master May 29, 2020
@NickGerleman
Copy link
Contributor

Removing the Backport to 0.62 label, since we need to rename it as part of the deprecation in favor of Request Backport which was already added to this PR. Triage of this item should still happen soon.

@stecrain
Copy link
Contributor

stecrain commented Jun 8, 2020

Is this going to be back-ported?

@acoates-ms
Copy link
Contributor Author

@stecrain - yes it is going to be back-ported.

@Khalef1
Copy link
Contributor

Khalef1 commented Jun 8, 2020

Approved for backport by triage

acoates-ms added a commit to acoates-ms/react-native-windows that referenced this pull request Jun 9, 2020
…FromTag (microsoft#5034)

* Add XamlUIService with ElementFromReactTag

* formatting

* Change files

* XamlUIService shouldn't be part of desktop dll
ghost pushed a commit that referenced this pull request Jun 10, 2020
…FromTag (#5034) (#5161)

* Add XamlUIService with ElementFromReactTag

* formatting

* Change files

* XamlUIService shouldn't be part of desktop dll
@acoates-ms acoates-ms deleted the elementFromTag branch June 10, 2020 16:13
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AutoMerge Causes a PR to be automatically merged once all requirements are passed (label drives bot activity)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Microsoft.ReactNative needs equivalent to ReactUWP FindShadowNodeForTag

6 participants