Just Code‎ > ‎

Silverlight - Binded value need to be updated when text is changed, not only when focus is lost.

posted May 20, 2010, 11:27 PM by Peter Henell   [ updated May 20, 2010, 11:43 PM ]
private void FilterTextbox_TextChanged(object sender, TextChangedEventArgs e)
        {
            TextBox tb = sender as TextBox;
            
            if(tb != null)
                tb.GetBindingExpression(TextBox.TextProperty).UpdateSource();

        }

<TextBox x:Name="FilterTextbox" 
Text="{Binding FilterListValue, Source={StaticResource vmMerchants}, Mode=TwoWay}"
TextChanged="FilterTextbox_TextChanged" Width="200" > <interaction:Interaction.Triggers> <interaction:EventTrigger EventName="KeyDown" > <behavior:TextBoxEnterButtonInvoke TargetName="FilterButton" /> </interaction:EventTrigger> </interaction:Interaction.Triggers> </TextBox>
Comments