I unable to get child control from ListBox control in WPF using MVVM -
i in serious trouble. have listbox control in have many combo box. whenever select value in combo box, have make other controls hidden. using mvvm pattren. unable child controls listbox control can listbox control in viewmodel. how can these controls in viewmodel? possible? using framework 4.0. have shown code below write in view.
<listbox x:name="lstitems" maxheight="300" fontsize="11" margin="12,0,20,38" itemssource="{binding source={staticresource listedview}, path=myitemssource, updatesourcetrigger=propertychanged, mode=twoway}"> <listbox.itemtemplate > <datatemplate> <border borderbrush="blue" margin="0,4,0,4" borderthickness="1" cornerradius="5"> <stackpanel orientation="horizontal"> <label content="show rules where:" name="lblshowrules"></label> <combobox x:name="cboshowrulewhere" height="20" width="200" itemssource="{binding source={staticresource listedview}, path=filterrules}" displaymemberpath="rulename" selectedvaluepath="ruleid" selectedvalue="{binding source={staticresource listedview}, path=selectedrulename, updatesourcetrigger=propertychanged, mode=twoway}" ></combobox> <grid height="29" horizontalalignment="left" name="grid1" verticalalignment="top" width="496" grid.row="1" margin="0,0,0,0"> <combobox height="21" horizontalalignment="left" margin="6,4,0,0" x:name="cborulecondtion" verticalalignment="top" width="212" /> <textbox height="20" horizontalalignment="left" margin="242,3,0,0" x:name="txtvalue" verticalalignment="top" width="245" visibility="hidden"/> <combobox height="21" horizontalalignment="left" margin="224,3,0,0" x:name="cbovalue" verticalalignment="top" width="205" visibility="hidden" /> <datepicker height="28" horizontalalignment="left" margin="242,-3,0,0" x:name="dtpfromdate" verticalalignment="top" width="98" visibility="hidden" /> <datepicker height="31" horizontalalignment="left" margin="346,-3,0,0" x:name="dtptodate" verticalalignment="top" width="98" visibility="hidden"/> </grid> <button name="cmdaddlevel" padding="0" margin="-1,1,0,-1" width="75" command ="{binding source={staticresource listedview}, path=addlevelcommand, updatesourcetrigger=propertychanged}" borderbrush="white" borderthickness="1" height="25" horizontalcontentalignment="center"> <stackpanel orientation="horizontal"> <image height="16" width="16" horizontalalignment="left" margin="1,0,0,-1"> </image> <textblock text="add level" fontweight="bold" height="16" width="70" horizontalalignment="right" verticalalignment="center" margin="8,2,0,-1" /> </stackpanel> </button> <label name="lbldeletelevel" margin="3,0,0,0" width="75" tabindex="7" horizontalalignment="left"> <hyperlink > <textblock text="delete level" /> </hyperlink> </label> </stackpanel> </border> </datatemplate> </listbox.itemtemplate> <listbox.itemspanel> <itemspaneltemplate> <stackpanel orientation="vertical" /> </itemspaneltemplate> </listbox.itemspanel> </listbox>
please me. once again, want know how child control parent control... possible?
using mvvm pattern, should not referencing of controls directly. alternatively, should create boolean property on viewmodel decides if various controls should visible. bind visibility property of controls want hide property, using converter.
see previous q/a details on visibility converters: link
Comments
Post a Comment