void EditContext_LayoutRequested(CoreTextEditContext sender, CoreTextLayoutRequestedEventArgs args) { CoreTextLayoutRequest request = args.Request; // Get the screen coordinates of the entire control and the selected text. // This information is used to position the IME candidate window. // First, get the coordinates of the edit control and the selection // relative to the Window. Rect contentRect = GetElementRect(ContentPanel); Rect selectionRect = GetElementRect(SelectionText); // Next, convert to screen coordinates in view pixels. Rect windowBounds = Window.Current.CoreWindow.Bounds; contentRect.X += windowBounds.X; contentRect.Y += windowBounds.Y; selectionRect.X += windowBounds.X; selectionRect.Y += windowBounds.Y; // Finally, scale up to raw pixels. double scaleFactor = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel; contentRect = ScaleRect(contentRect, scaleFactor); selectionRect = ScaleRect(selectionRect, scaleFactor); // This is the bounds of the selection. // Note: If you return bounds with 0 width and 0 height, candidates will not appear while typing. request.LayoutBounds.TextBounds = selectionRect; //This is the bounds of the whole control request.LayoutBounds.ControlBounds = contentRect; }
void EditContext_LayoutRequested(CoreTextEditContext sender, CoreTextLayoutRequestedEventArgs args) { CoreTextLayoutRequest request = args.Request; request.LayoutBounds.TextBounds = _textInputRect; }