mvvm - WPF ComboBox SelectionChanged event to command not firing -


i have following xaml of combobox has code-behind selectionchanged event handler , command property of viewmodel. have set selectedindex property 0. when run project, code-behind handler invoked, command not executed. want command should executed selectedindex=0 first time view loaded.

<combobox name="listcombobox" selectionchanged="listcombobox_selectionchanged" selectedindex="0" selectedvaluepath="content" margin="5,0" height="35" width="150" verticalalignment="center" horizontalalignment="left">     <i:interaction.triggers>         <i:eventtrigger eventname="selectionchanged">             <i:invokecommandaction command="{binding listtypecomboselectionchangedcmd}" commandparameter="{binding elementname=listcombobox, path=selectedvalue}"/>         </i:eventtrigger>      </i:interaction.triggers>      <comboboxitem content="itemone" />      <comboboxitem content="itemtwo" />      <comboboxitem content="itemthree" /> </combobox> 

update

code-behind event handler:

private void listcombobox_selectionchanged(object sender, selectionchangedeventargs e) { } 

icommand object:

public icommand listtypecomboselectionchangedcmd  {      { return new relaycommand<string>(listtypecomboselectionchangedcmdexec); }     private set; } 

icommand handler:

private void listtypecomboselectionchangedcmdexec(string listtype) { } 

bind selectedvalue property on view model.

in property set{...} block logic there or call

listtypecomboselectionchangedcmdexec(value) 

see binding combobox selecteditem using mvvm


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -