文章分類/

Infragistics|Ultimate UI for WPF|XamNumericEditor:設置焦點時處理 GotFocus 事件,失去焦點時處理 LostFocus 事件

尚無瀏覽量
2023-09-03 更新

infragistics log

XamNumericEditor 在編輯時在內部生成一個單獨的編輯器。因此,當焦點在 XamNumericEditor 和基礎編輯器之間移動時設置焦點時,也會發生 LostFocus。
要處理焦點設置為 XamNumericEditor 時的 GotFocus 事件和焦點丟失時的 LostFocus 事件,請添加如下控制代碼。
private void xamNumericEditor1_GotFocus(object sender, RoutedEventArgs e)
{
    // 如果焦點位於 XamNumericEditor 的內部編輯器上,則設置為 True。
    if (e.OriginalSource.GetType() != typeof(XamNumericEditor))
    {
        System.Diagnostics.Debug.WriteLine("GotFocus");
    }
}

private void xamNumericEditor1_LostFocus(object sender, RoutedEventArgs e)
{
    // 如果焦點從 XamNumericEditor 的內部編輯器中移除,則設置為 True。
    // 還要考慮按Escape鍵的操作。
    if (e.OriginalSource.GetType() != typeof(XamNumericEditor) && Keyboard.IsKeyDown(Key.Escape) == false
        || Keyboard.IsKeyDown(Key.Escape)
        )
    {
        System.Diagnostics.Debug.WriteLine("LostFocus");
    }
}

快速跳轉目錄

✦ 群昱 AccessSoft 你的全面軟體解決方案 ✦

身為全球眾多知名軟體在台灣合作夥伴,歡迎諮詢你需要的軟體服務!

Picture of 軟體專家
軟體專家

群昱作為全球知名軟體推薦合作夥伴,致力於提供更多軟體解決方案給你!

更多軟體新知

立即詢價

請留下完整資訊,以便我們提供精確的服務內容給你。

詢價資訊