c# - WPF window doesn't get updated by property binding -
i have wpf form textbox defined in xaml file follows:
<textbox grid.column="1" grid.row="9" tabindex="0" x:name="txtboxexample" width="170" > <textbox.style> <style targettype="{x:type textbox}"> <setter property="visibility" value="hidden" /> <style.triggers> <datatrigger binding="{binding tooldatacontext.iteminstance.istoshow, mode=twoway}" value="true"> <setter property="visibility" value="visible" /> </datatrigger> </style.triggers> </style> </textbox.style> <textbox.text> <binding path="tooldatacontext.iteminstance.usertext" updatesourcetrigger="propertychanged" /> </textbox.text> </textbox> ... <button click="somebtn_click" content="{x:static res:strings.buttonstring}" name="somebutton">
on xaml.cs file have following code:
private void somebtn_click(object sender, routedeventargs e) { ... tooldatacontext.iteminstance.istoshow = true; ... }
in item class have following code property istoshow:
public class item : syncableobject, isearchableobject, inotifypropertychanged { ... private bool _istoshow; public bool istoshow { { return _istoshow; } set { if (value == _istoshow) return; _istoshow = value; this.onpropertychanged("istoshow"); } } ... new public event propertychangedeventhandler propertychanged; new public void onpropertychanged(string propertyname) { propertychangedeventhandler handler = this.propertychanged; if (handler != null) handler(this, new propertychangedeventargs(propertyname)); } ... }
i expect window show textbox when click when on button. doesn't happen.
can give me lead doing wrong?
try adding path data trigger binding
<datatrigger binding="{binding path=tooldatacontext.iteminstance.istoshow, mode=twoway}" value="true">
Comments
Post a Comment