SilverlightShow: Silverlight How to Command Control Comments Silverlight articles, Silverlight tutorials, Silverlight videos, Silverlight samples Argotic Syndication Framework 2008.0.2.0, en-US (Emil Stoychev) Re: Silverlight How to Command Control good application and nice idea AssemHomidy Fri, 23 Sep 2011 21:05:05 GMT RE: Silverlight How to Command Control <p>Hi, </p> <p>I am unable to find "Command" property in designer while trying to set it for "Button" control.</p> <p>I am trying to do this in Silverlight targetting Framework 3, and has not added any special reference as such. Am I missing anything here? However, I have added reference to the DLL where I have created a class implemented from ICommand intereface.    </p> <p>Any help on this, much appreciated.</p> Nirman Doshi, Vadodara Tue, 17 May 2011 10:16:08 GMT RE: Silverlight How to Command Control Is their any way, so that i can bind the button from code behind. I need this kind of scenario when i am dynamically generating the buttons i a user control. Thanks in advance. Paras Sharma Tue, 26 Apr 2011 10:39:28 GMT RE: Silverlight 4 How to Command Control <p>Commands not being Invoked in my View Model Class.</p> <p>Hi , I am developing an MVVM Application. I am following the above method u sugggested.</p> <p>I have a listBox showing all the Employee Names and beside it is the details of every employee.</p> <p>On click of a diffrent employee from the listBox we get the details of the Next Employee.</p> <p>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.</p> <p>--VIEW CLASS-------------------------------------------------------------------</p> <p><ListBox Name="lstMiners" Grid.Row="0" Grid.Column="0" Margin="5"<br />                  ItemsSource="{Binding Path=MinerList, Mode=TwoWay}"<br />                  SelectedItem="{Binding Path=SelectedMiner, Mode=TwoWay}" ><br />                 <ListBox.ItemTemplate><br />                     <DataTemplate><br />                         <StackPanel Orientation="Horizontal"><br />                             <TextBlock Text="{Binding Miner_First_Name}" FontWeight="Bold" />                            <br />                         </StackPanel><br />                     </DataTemplate><br />                 </ListBox.ItemTemplate><br />             </ListBox></p> <p><Grid x:Name="MinerDetails" Grid.Column="1" Grid.Row="0" <br />                   DataContext="{Binding Path=SelectedMiner, Mode=TwoWay}" <br />                       Margin="5" Background="LightGray"><br />                 <Grid.ColumnDefinitions><br />                     <ColumnDefinition Width="100" /><br />                     <ColumnDefinition Width="100" /><br />                 </Grid.ColumnDefinitions><br />                 <Grid.RowDefinitions><br />                     <br />                     <RowDefinition Height="20" /><br />                     <RowDefinition Height="20" /><br />                     <RowDefinition Height="20" /><br />                     ......<br />                 </Grid.RowDefinitions></p> <p>                <br />                 <TextBlock Grid.Row="1" Grid.Column="0" Text="Miner_id:"  /><br />                 <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Path=Miner_id, Mode=TwoWay}" IsEnabled="False" /><br />                 <TextBlock Grid.Row="2" Grid.Column="0" Text="First Name:" /><br />                 <TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Path=Miner_First_Name,Mode=TwoWay}" /><br />                 <TextBlock Grid.Row="3" Grid.Column="0" Text="Last Name:" /><br />                 <TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Path=Miner_Last_Name,Mode=TwoWay}" /><br />                 .....</p> <p>            </Grid></p> <p> <StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Left"        DataContext="Binding"><br />             ... <Button Command="{Binding SaveCommand}"     Content="Save" Height="25" Width="100" Background="Aqua"></Button><br />         </StackPanel></p> <p>--VIEW MODEL CLASS----------------------------------------------------------------------------------------------------------</p> <p>        public ICommand SaveCommand { get; set; }        </p> <p >In Constructor...</p> <p>public MinerMasterVM()<br />         {<br />             SaveCommand = new DelegateCommand(SaveMiner, CanSaveMiner);<br />             MinerServiceClient msClient = new MinerServiceClient();<br />             msClient.GetMinersCompleted += new EventHandler<GetMinersCompletedEventArgs>(msClient_GetMinersCompleted);<br />             msClient.GetMinersAsync();<br />         }</p> <p>public void SaveMiner(object parameter)<br />         {<br />             ....<br />         }</p> <p>        void msClient_UpdateMinerCompleted(object sender, UpdateMinerCompletedEventArgs e)<br />         {<br />             throw new NotImplementedException();<br />         }</p> <p>        private bool CanSaveMiner(object parameter)<br />         {<br />             return true;<br />         }</p> <p>-----------------------------------------------------------------------------------------------------</p> <p>I am calling the View XMAL file from the MainPage.XMAL.</p> <p><</p> <p>views:MinerView x:Name="MinerDataView"></views:MinerView></p> <p> MinerMasterVM mVM = new MinerMasterVM();</p> <p>MinerDataView.DataContext = mVM;</p> <p > </p> <p>All my VM objects are accessible . But not the Commands .</p> <p>Not sure Why . Can some body through some light on it.</p> <p>Regards</p> <p>Debashish</p> Debashish Gupta Thu, 29 Jul 2010 17:48:28 GMT RE: Silverlight 4 How to Command Control This is cool. I've been meaning to look into MVVM for a while now. One thing I've often wondered. How are errors handled? In your above code snippits, what happens if the save command throws an error? How is that sent back to the user so they can correct any mistakes and try again? Adam Wed, 03 Feb 2010 16:31:55 GMT