Skip to content

Latest commit

 

History

History
61 lines (45 loc) · 2.73 KB

richeditbox_candidatewindowboundschanged.md

File metadata and controls

61 lines (45 loc) · 2.73 KB
-api-id -api-type
E:Microsoft.UI.Xaml.Controls.RichEditBox.CandidateWindowBoundsChanged
winrt event

Microsoft.UI.Xaml.Controls.RichEditBox.CandidateWindowBoundsChanged

-description

Occurs when the Input Method Editor (IME) window open, updates, or closes.

-xaml-syntax

<RichEditBox CandidateWindowBoundsChanged="eventhandler" />

-remarks

For event data, see CandidateWindowBoundsChangedEventArgs.

Users sometimes enter text through an Input Method Editor (IME) that shows in a window just below a text input box (typically for East Asian languages). The Input Method Editor (IME) window can cover important parts of your app UI that the user might need to see while entering text. This event notifies your app of the coordinates where the Input Method Editor (IME) window is currently displayed. You can use this info to draw your UI in a location that doesn't conflict with the Input Method Editor (IME) window.

You can also use the DesiredCandidateWindowAlignment property to specify a preferred placement of the Input Method Editor (IME) window in relation to the text input box.

-examples

Here, a rectangle is placed below a RichEditBox. When the Input Method Editor (IME) window bounds change, the bottom Margin of the RichEditBox is increased by the height of the Input Method Editor (IME) candidate window. As a result, the rectangle is pushed down by that amount and is not covered by the candidate window.

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <StackPanel>
        <RichEditBox x:Name="editBox1" Width="300" HorizontalAlignment="Left" 
                 DesiredCandidateWindowAlignment="BottomEdge"
                 CandidateWindowBoundsChanged="OnCandidateWindowBoundsChanged"/>
        <Rectangle Height="100" Width="100" Fill="Red" 
                   HorizontalAlignment="Left"/>
    </StackPanel>
</Grid> 
private void OnCandidateWindowBoundsChanged(RichEditBox sender, CandidateWindowBoundsChangedEventArgs args) 
{ 
    editBox1.Margin = new Thickness 
    { 
        Left = 0, 
        Top = 0, 
        Right = 0, 
        Bottom = Math.Max(0, args.Bounds.Bottom - editBox1.ActualHeight) 
    };
} 

-see-also

DesiredCandidateWindowAlignment, CandidateWindowBoundsChangedEventArgs