Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6690889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:41:19+00:00 2026-05-26T05:41:19+00:00

I have a listview. I have set following int that :- <ListView KeyboardNavigation.TabNavigation=Local SelectionMode=Extended>

  • 0

I have a listview. I have set following int that :-

<ListView KeyboardNavigation.TabNavigation="Local" SelectionMode="Extended">
 <ListView.ItemContainerStyle>
  <Style>
     <Setter Property="KeyboardNavigation.IsTabStop" Value="False"/>
  </Style>
</ListView.ItemContainerStyle>

One column in listview contains TextBox’s.

If I set the UpdateSourceTrigger=LostFocus
in my textbox, I can not tab through the listview…Instead if I set UpdateSourceTrigger=Explicit, the tabbing is working…but source will not get updated.

Please help me

EDIT

public class TextBoxBehavior
    {
        #region Attached Property EscapeClearsText


        public static readonly DependencyProperty EscapeClearsTextProperty
           = DependencyProperty.RegisterAttached("EscapeClearsText", typeof(bool), typeof(TextBoxBehavior),
                new FrameworkPropertyMetadata(false, new PropertyChangedCallback(OnEscapeClearsTextChanged)));


        private static void OnEscapeClearsTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if ((bool)e.NewValue)
            {
                var textBox = d as TextBox;
                if (textBox != null)
                {
                    textBox.KeyUp -= TextBoxKeyUp;
                    textBox.KeyUp += TextBoxKeyUp;
                }
            }
        }


        private static void TextBoxKeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Escape)
            {
                //((DataContext<string>)((TextBox)sender).GetBindingExpression(TextBox.TextProperty).DataItem).RollbackChanges();
                ((TextBox)sender).Text = string.Empty;
            }
            else if (e.Key == Key.Enter)
            {                
                ((TextBox)sender).GetBindingExpression(TextBox.TextProperty).UpdateSource();
                                }
        }

        public static void SetEscapeClearsText(DependencyObject dependencyObject, bool escapeClearsText)
        {
            if (!ReferenceEquals(null, dependencyObject))
                dependencyObject.SetValue(EscapeClearsTextProperty, escapeClearsText);
        }


        public static bool GetEscapeClearsText(DependencyObject dependencyObject)
        {
            if (!ReferenceEquals(null, dependencyObject))
                return (bool)dependencyObject.GetValue(EscapeClearsTextProperty);
            return false;
        }


        #endregion Attached Property EscapeClearsText
    }

Below is the listview/gridview column which has the attached property in it.

 <GridViewColumn  Width="60">
                                            <GridViewColumnHeader Content="Priority"
                                              Command="{Binding Path=SortSelectedClaimCodeGroupsCommand}"
                                              CommandParameter="Item.IntPriority">
                                            </GridViewColumnHeader>
                                            <GridViewColumn.CellTemplate>
                                                <DataTemplate>
                                                    <Border DataContext="{Binding Item.Priority}"
                                                        Style="{StaticResource ValidationResultBorderStyle}" HorizontalAlignment="Left" >
                                                        <TextBox Width="200" MaxLength="25" Text="{Binding Path=Value,Mode=TwoWay,                         
                                                            UpdateSourceTrigger=Explicit}" local:TextBoxBehavior.EscapeClearsText="True" >
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:41:19+00:00Added an answer on May 26, 2026 at 5:41 am

    When you set the UpdateSourceTrigger as explicit, you have to update the source by explicitly calling the method UpdateSource on your BindingExpression. Where is the code for that?

    EDIT

    In your TextBoxKeyUp event you are overwriting your Binding by setting the text on the press of Escape key. Firstly you bind it to the property Value and later you are explicitly setting the Textbox text property to String.Empty.This way text property will loose it’s binding. So, later whenever you call UpdateSource it won’t propagate to Source value since it’s no longer binded to the Text property of textbox. Instead you should set the text like this –

    ((TextBox)sender).SetCurrentValue(TextBox.TextProperty, String.Empty);
    

    This way your binding will be preserved and UpdateSource would work as it should.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have ListView that has the following EditItemTemplate: <EditItemTemplate> <tr style=> <td> <asp:LinkButton ID=UpdateButton
I have the following ListView: <ListView Name=listView> <ListView.View> <GridView> <GridView.ColumnHeaderContainerStyle> <Style TargetType={x:Type GridViewColumnHeader}> <Setter
I have the following problem. The background color in a ListView is set LightGreen
I have a ListView that is set up with a MinHeight and a MaxHeight.
I have a Listview that looks like the following: checkbox:textview {0 .. n} I
Hi i have a ListView that binds to a collection. I set the height
I have a ListView control set up in details mode with 5 columns. It
I have a listview of width set to Auto. When I run the windows
I have a ListView control on my form set up like this in details
I have an empty TextView set for my ListView . When there is no

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.