Share via


TextBox.CandidateWindowBoundsChanged Event

Definition

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

public event TypedEventHandler<TextBox,CandidateWindowBoundsChangedEventArgs> CandidateWindowBoundsChanged;
<TextBox CandidateWindowBoundsChanged="eventhandler" />

Event Type

Examples

Here, a rectangle is placed below a TextBox. When the Input Method Editor (IME) window bounds change, the bottom Margin of the TextBox 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>
        <TextBox x:Name="textBox1" Width="300" HorizontalAlignment="Left"
                 DesiredCandidateWindowAlignment="BottomEdge"
                 CandidateWindowBoundsChanged="OnCandidateWindowBoundsChanged"/>
        <Rectangle Height="100" Width="100" Fill="Red"
                   HorizontalAlignment="Left"/>
    </StackPanel>
</Grid>
private void OnCandidateWindowBoundsChanged(TextBox sender, CandidateWindowBoundsChangedEventArgs args)
{
    textBox1.Margin = new Thickness
    {
        Left = 0,
        Top = 0,
        Right = 0,
        Bottom = Math.Max(0, args.Bounds.Bottom - textBox1.ActualHeight)
    };
}

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.

Applies to

Product Versions
WinRT Build 10240, Build 10586, Build 14383, Build 15063, Build 16299, Build 17134, Build 17763, Build 18362, Build 19041, Build 20348, Build 22000, Build 22621, Build 26100

See also