Hi , I am developing an MVVM Application. I am following the http://johnpapa.net/Silverlight/5-simple-steps-to-commanding-in-silverlight/
I have a listBox showing all the Employee Names and beside it is the details of every employee.
On click of a diffrent employee from the listBox we get the details of the Next Employee.
I have also kept 4 Commands . But i am not sure why my commands in the VM is not getting called on click from View.
--VIEW CLASS-------------------------------------------------------------------
ItemsSource="{Binding Path=MinerList, Mode=TwoWay}" SelectedItem="{Binding Path=SelectedMiner, Mode=TwoWay}" >
DataContext="{Binding Path=SelectedMiner, Mode=TwoWay}" Margin="5" Background="LightGray"> ......
.....
...
--VIEW MODEL CLASS----------------------------------------------------------------------------------------------------------
public ICommand SaveCommand { get; set; }
In Constructor...
public MinerMasterVM() { SaveCommand = new DelegateCommand(SaveMiner, CanSaveMiner); MinerServiceClient msClient = new MinerServiceClient(); msClient.GetMinersCompleted += new EventHandler(msClient_GetMinersCompleted); msClient.GetMinersAsync(); }
public void SaveMiner(object parameter) { .... }
void msClient_UpdateMinerCompleted(object sender, UpdateMinerCompletedEventArgs e) { throw new NotImplementedException(); }
private bool CanSaveMiner(object parameter) { return true; }
-----------------------------------------------------------------------------------------------------
I am calling the View XMAL file from the MainPage.XMAL.
<
views:MinerView x:Name="MinerDataView">
MinerMasterVM mVM = new MinerMasterVM();
MinerDataView.DataContext = mVM;
All my VM objects are accessible . But not the Commands . Not sure Why . Can some body through some light on it.
Regards
Debashish
|
No responses found. Be the first to respond and make money from revenue sharing program.
|