Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WCF and WF
  4. binded TextBox update only on focus lost

binded TextBox update only on focus lost

Scheduled Pinned Locked Moved WCF and WF
helpannouncement
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Abs59
    wrote on last edited by
    #1

    I am Using a Textbox and a button for submiting textbox text , the button should be unavailable if there is No text , but , the textbox "Updates" her Binded property (whitch used by buttun can execute comman ) after it lost focus , and I want the text box to update after each keystroke , I know there is a property that can solve my problem I cant remmember how it's called thenk you ...

    M 1 Reply Last reply
    0
    • A Abs59

      I am Using a Textbox and a button for submiting textbox text , the button should be unavailable if there is No text , but , the textbox "Updates" her Binded property (whitch used by buttun can execute comman ) after it lost focus , and I want the text box to update after each keystroke , I know there is a property that can solve my problem I cant remmember how it's called thenk you ...

      M Offline
      M Offline
      mikla521
      wrote on last edited by
      #2

      At this moment, I'm one of them putting up a lot of questions here but I actually can solve your problem. In my way of course :)

      <TextBox Name="tb1" ></TextBox>
      <Button Height="23" IsEnabled="{Binding ElementName=tb1, Path=Text, Converter={StaticResource StringBoolConverter}}"></Button>

      and a ValueConverter like this

      public class StringToBoolConverter : IValueConverter
      {
      #region IValueConverter Members
      public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
      if (value.ToString() == "")
      return false;

              return true;
          }
      
          public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
          {
              throw new NotImplementedException();
          }
          #endregion
      }
      

      and in your resource

      <local:StringToBoolConverter x:Key="StringBoolConverter" />

      B 1 Reply Last reply
      0
      • M mikla521

        At this moment, I'm one of them putting up a lot of questions here but I actually can solve your problem. In my way of course :)

        <TextBox Name="tb1" ></TextBox>
        <Button Height="23" IsEnabled="{Binding ElementName=tb1, Path=Text, Converter={StaticResource StringBoolConverter}}"></Button>

        and a ValueConverter like this

        public class StringToBoolConverter : IValueConverter
        {
        #region IValueConverter Members
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
        if (value.ToString() == "")
        return false;

                return true;
            }
        
            public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                throw new NotImplementedException();
            }
            #endregion
        }
        

        and in your resource

        <local:StringToBoolConverter x:Key="StringBoolConverter" />

        B Offline
        B Offline
        BrowniePoints
        wrote on last edited by
        #3

        It's actually simpler than that. You have to explicitly set the UpdateSourceTrigger on your binding to PropertyChanged. [^]

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups