Delen via


TextBox.CandidateWindowBoundsChanged Event

Definition

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

// Register
event_token CandidateWindowBoundsChanged(TypedEventHandler<TextBox, CandidateWindowBoundsChangedEventArgs const&> const& handler) const;

// Revoke with event_token
void CandidateWindowBoundsChanged(event_token const* cookie) const;

// Revoke with event_revoker
TextBox::CandidateWindowBoundsChanged_revoker CandidateWindowBoundsChanged(auto_revoke_t, TypedEventHandler<TextBox, CandidateWindowBoundsChangedEventArgs const&> const& handler) const;
public event TypedEventHandler<TextBox,CandidateWindowBoundsChangedEventArgs> CandidateWindowBoundsChanged;
function onCandidateWindowBoundsChanged(eventArgs) { /* Your code */ }
textBox.addEventListener("candidatewindowboundschanged", onCandidateWindowBoundsChanged);
textBox.removeEventListener("candidatewindowboundschanged", onCandidateWindowBoundsChanged);
- or -
textBox.oncandidatewindowboundschanged = onCandidateWindowBoundsChanged;
Public Custom Event CandidateWindowBoundsChanged As TypedEventHandler(Of TextBox, CandidateWindowBoundsChangedEventArgs) 
<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

See also