c# - INotifyPropertyChanged does not work when the property set to another value with mode = twoway -


my xaml

<textbox text="{binding myval, mode=twoway}" ></textbox> 

my viewmodel

private string myvar;      public string myval     {                 {             return myvar;         }         set         {             if (value.length > 6)                 myvar = value;             else                 myvar = "not valid input";             onpropertychanged("myval");         }     }     public event propertychangedeventhandler propertychanged;      public void onpropertychanged(string name)     {         propertychangedeventhandler handler = propertychanged;         if (handler != null)         {             handler(this, new propertychangedeventargs(name));         }     } 

when ever user enters less 6 char string textbox should disply error message. instead of textbox text remains same user input. variable value changing expected.

i'm using winrt app please in advance.

i change xaml code way :

<textbox text="{binding myval, mode=twoway, updatesourcetrigger=propertychanged}" ></textbox> 

now every time property change, view notified.

and if ui still not updated try adding isasync=true :

<textbox text="{binding myval, mode=twoway, isasync=true}"></textbox> 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -