c# - UWP TextBox.Text binding not updating when using PlaceholderText -
i've got text boxes wanted set placeholdertext
property. text of each box bound property of underlying view model. when setting placeholder in xaml that
<textbox placeholdertext="placeholder" text={binding propertyname} />
i noticed, view model's properties not updated anymore when text box loses focus. whereas without placeholder binding works fine.
is behaviour intended , if there workarounds, or have stick classic textblock
describes intended input each box?
edit: property implement inotifypropertychanged
, binding updated in view model when no placeholder set.
placeholdertext textbox not change textbox behavior when loses focus.
you can try explicitly using "twoway" binding mode text property, instead of "default" binding mode.
<textbox placeholdertext="placeholder" text="{x:bind propertyname, mode=twoway}" />
make sure view's datacontext set viewmodel, below
public mainpage() { this.datacontext = new mainviewmodel(); this.initializecomponent(); }
for more information on binding mode, see to
https://msdn.microsoft.com/en-us/library/windows/apps/mt204783.aspx
Comments
Post a Comment