-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Area: Native ModulesNeeds: Dev DesignPartner: OfficePartner: Xbox(label may be applied by bot based on author)(label may be applied by bot based on author)enhancement
Milestone
Description
Summary
Add a function, possibly to IReactContext, that allows Native Modules to pass in a node id (the value returned by findNodeHandle() in JS) and get access to the corresponding XAML view.
Motivation
Native modules need the ability to find and act upon arbitrary XAML elements. This allows use of native modules to augment existing UI elements.
For example, XAML's UIElement provides the "StartBringIntoView" function that will trigger any containing scroll region to scroll until the element is visible. Rather than updating all existing ViewManagers to include this function, a native module could be written to enable the behavior.
REACT_MODULE(ScrollHelperModule);
class ScrollHelperModule {
REACT_METHOD(startBringIntoView);
void startBringIntoView(int nodeHandle) noexcept {
m_reactInstance->FindViewByHandle(nodeHandle).as<winrt::UIElement>().StartBringIntoView();
}
}
const ScrollHelper = NativeModules.ScrollHelperModule;
export function startBringIntoView(target: Component) {
return ScrollHelper.startBringIntoView(findNodeHandle(target));
}
Metadata
Metadata
Assignees
Labels
Area: Native ModulesNeeds: Dev DesignPartner: OfficePartner: Xbox(label may be applied by bot based on author)(label may be applied by bot based on author)enhancement