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 8772403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:01:23+00:00 2026-06-13T18:01:23+00:00

A follow the MVVM pattern. I need the TextBox to trigger a property setter

  • 0

A follow the MVVM pattern. I need the TextBox to trigger a property setter on the viewModel every time the Text in the TextBox changes. The problem is that the setter on ViewModel is never called. This is what I’ve got:

View (.cs)

public partial class AddShowView : PhoneApplicationPage
{
    public AddShowView()
    {
        InitializeComponent();
    }

    private void PhoneApplicationPage_Loaded_1(object sender, RoutedEventArgs e)
    {
        DataContext = new AddShowViewModel(this.NavigationService);
    }

    private void SearchTextBox_TextChanged_1(object sender, TextChangedEventArgs e)
    {
        var textBox = (TextBox)sender;
        var binding = textBox.GetBindingExpression(TextBox.TextProperty);
        binding.UpdateSource();
    }
}

View (.xaml), only the relevant part

<TextBox Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Center" Text="{Binding SearchText, UpdateSourceTrigger=Explicit}" TextChanged="SearchTextBox_TextChanged_1" />

ViewModel

public class AddShowViewModel : PageViewModel
{
    #region Commands

    public RelayCommand SearchCommand { get; private set; }

    #endregion

    #region Public Properties

    private string searchText = string.Empty;
    public string SearchText
    {
        get { return searchText; }
        set
        {
            searchText = value;
            SearchCommand.RaiseCanExecuteChanged();
        }
    }

    #endregion

    public AddShowViewModel(NavigationService navigation) : base(navigation)
    {
        SearchCommand = new RelayCommand(() => MessageBox.Show("Clicked!"), () => !string.IsNullOrEmpty(SearchText));
    }
}

The binding from source to target works, I’ve double checked, so the DataContext is set correctly. I have no idea where I went wrong.
Thanks for helping out.

  • 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-06-13T18:01:24+00:00Added an answer on June 13, 2026 at 6:01 pm

    You need to set the binding mode to be TwoWay, otherwise it’ll only read the value from your ViewModel, not update it.

    Text="{Binding SearchText, Mode=TwoWay, UpdateSourceTrigger=Explicit}"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am required to use the mvvm pattern. I know that the viewmodel should
Could you tell me which is the best MVVM pattern someone have to follow
Background I have a TreeView that follows the MVVM design pattern and supports multiple
I'll start out by saying that I'm trying to follow MVVM as strictly as
I am working with Attached Property in MVVM and encountered a interesting problem. I
I am building a WPF app that is based on the MVVM pattern (using
We have a WPF Project that follows the MVVM pattern. In the View Model
I'm trying to follow the MVVM pattern laid out here: http://msdn.microsoft.com/en-us/magazine/dd419663.aspx#id0090097 I have this
My problem is as follows: I am working with MVVM pattern and I would
I am using WPF, and attempting to follow the MVVM pattern. Our team has

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.