c# - HowTo set IsChecked Property false of all ToggleButtons in a StackPanel -
how can list existing togglebuttons in stackpanel , set ischecked property false in code-behind ?
i started with:
list<togglebutton> togglebuttons = togglebtnlistsp.children.oftype<togglebutton>().tolist(); foreach(var item in togglebuttons) { item.ischecked = false; } but im stuck , don't know how confirm.
here xaml:
<!-- private customer rights --> <stackpanel x:name="togglebtnlistsp"> <groupbox x:name="customerrightsgroupbox" header="customer rights" margin="10,10,10.2,0" verticalalignment="top" height="108"> <grid> <grid.columndefinitions> <columndefinition /> <columndefinition /> </grid.columndefinitions> <stackpanel margin="0,0,5,0"> <dockpanel lastchildfill="false"> <label content="can add:" dockpanel.dock="left" /> <togglebutton x:name="can_add_customer" dockpanel.dock="right"></togglebutton> </dockpanel> <dockpanel lastchildfill="false"> <label content="can create assignment:" dockpanel.dock="left" /> <togglebutton x:name="can_add_assignment_customer" dockpanel.dock="right"></togglebutton> </dockpanel> </stackpanel> <stackpanel grid.column="1" margin="5,0,0,0"> <dockpanel lastchildfill="false"> <label content="can delete:" dockpanel.dock="left" /> <togglebutton x:name="can_delete_customer" dockpanel.dock="right"></togglebutton> </dockpanel> <dockpanel lastchildfill="false"> <label content="can edit:" dockpanel.dock="left" /> <togglebutton x:name="can_edit_customer" dockpanel.dock="right"></togglebutton> </dockpanel> </stackpanel> </grid> </groupbox> <!-- firm customer rights --> <groupbox x:name="firmcustomerrightsgroupbox" header="firmcustomer rights" margin="10,10,10,0" verticalalignment="top" height="108"> <grid> <grid.columndefinitions> <columndefinition /> <columndefinition /> </grid.columndefinitions> <stackpanel margin="0,0,5,0"> <dockpanel lastchildfill="false"> <label content="can add:" dockpanel.dock="left" /> <togglebutton x:name="can_add_firmcustomer" dockpanel.dock="right"></togglebutton> </dockpanel> <dockpanel lastchildfill="false"> <label content="can create assignment firmcustomer" dockpanel.dock="left" fontsize="12" /> <togglebutton x:name="can_add_assignment_firmcustomer" dockpanel.dock="right"></togglebutton> </dockpanel> </stackpanel> <stackpanel grid.column="1" margin="5,0,0,0"> <dockpanel lastchildfill="false"> <label content="can delete:" dockpanel.dock="left" /> <togglebutton x:name="can_delete_firmcustomer" dockpanel.dock="right"></togglebutton> </dockpanel> <dockpanel lastchildfill="false"> <label content="can edit:" dockpanel.dock="left" /> <togglebutton x:name="can_edit_firmcustomer" dockpanel.dock="right"></togglebutton> </dockpanel> </stackpanel> </grid> </groupbox> </stackpanel> i read false or true database. if click on "add" want togglebuttons ischecked="false"
instead of adding list, rather create 1 linq command
creates list , itterates you
yourstackpanel.children .oftype<togglebutton>().tolist() .foreach(togglebutton => togglebutton.ischecked = false);
Comments
Post a Comment