c# - Determining checked Radiobutton from groupbox in WPF following MVVM -
i have groupbox radiobuttons. how know 1 checked. using wpf , following mvvm.
please excuse me if duplicate question , did enough googling.
<groupbox name="grpbx_pagerange" header="print range"> <grid > <radiobutton name="radbtn_all" content="all pages" groupname="radios_page_range" ischecked="true" /> <radiobutton x:name="radbtn_curr" content="current page" groupname="radios_page_range" /> <radiobutton name="radbtn_pages" content="page range" groupname="radios_page_range" /> .... </groupbox>
now, 1 way figure out bind each radiobutton's ischecked
property property in viewmodel , if..else sort of logic in viewmodel figure out selected radiobutton.
but there other eligant way? new mvvm , not expert in wpf - please excuse if solution silly. smile
thanks in advance.
you can bind radiobutton.command
of radiobuttons command of viewmodel , send unique commandparameter identify button has called command in commandhandler.
<radiobutton command="{binding mycommand}" commandparameter="radio1"/> <radiobutton command="{binding mycommand}" commandparameter="radio2"/> <radiobutton command="{binding mycommand}" commandparameter="radio3"/>
in command handler check parameter identify radiobutton.
thanks
Comments
Post a Comment