Immediate Update in binding expression

Topics: Getting Started
Feb 28, 2012 at 11:15 AM

Hi

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()
        {
            myview.loopingList.Focus();
            _imagesearchService.GetImages(OnSearchCompleted, SearchText);
        }

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

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

Feb 28, 2012 at 12: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:

http://caliburnmicro.codeplex.com/wikipage?title=Basic%20Configuration%2c%20Actions%20and%20Conventions&referringTitle=Documentation

Feb 29, 2012 at 8:49 AM

Yep it worked Thanks