binded TextBox update only on focus lost
-
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 ...
-
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 ...
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" />
-
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" />
It's actually simpler than that. You have to explicitly set the UpdateSourceTrigger on your binding to PropertyChanged. [^]