Immediate Update in binding expression

Topics: Getting Started
Feb 28, 2012 at 12:15 PM


I am developing a WP7 app. I'm not sure what mistake I am doing but need some help to figure out this issue.

I have textbox called SearchText I have the appbar button in application bar called Search

I have defined methods Search and CanSearch.

The button can only execute when there is some value in searchtext property and I want this instantly not on the lost focus of the textbox.

I have written the following code. Please correct me where I am going wrong.

public void Search()
            _imagesearchService.GetImages(OnSearchCompleted, SearchText);

public bool CanSearch()
            return !string.IsNullOrWhiteSpace(SearchText);

 public string SearchText
            get { return _searchText; }
                _searchText = value;
               // NotifyOfPropertyChange(() => SearchText);

Feb 28, 2012 at 1:15 PM

If i'm not mistaken, You have to notify the Cansearch also, otherwise it won't check for it ever.

So in the setter of the SearchText Property, Do a NotifyOfPropertyChanged(()=>CanSearch); or RaisePropertyChangedEventImmediatly, whichever you need.


there is a more clear example here:

Feb 29, 2012 at 9:49 AM

Yep it worked Thanks