<Menu.CommandBindings>
<CommandBinding Command="Copy" CanExecute="CommandBinding_OnCanExecute"></CommandBinding>
</Menu.CommandBindings>
<MenuItem Header="Edit" >
<MenuItem Header="Copy" Command="Copy"></MenuItem>
</MenuItem>
private void CommandBinding_OnCanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = false;
e.Handled = true;
}
void Main()
{
List<IDriving> transports = new List<IDriving>();
transports.Add(new Car());
transports.Add(new Boat());
foreach (IDriving transport in transports)
{
transport.MoveForward();
transport.MoveBack();
}
}
// Define other methods and classes here
public interface IDriving
{
void MoveForward();
void MoveBack();
}
public class Car : IDriving
{
public void MoveForward()
{
Console.WriteLine ("Car move forward");
}
public void MoveBack()
{
Console.WriteLine ("Car move back");
}
}
public class Boat : IDriving
{
public void MoveForward()
{
Console.WriteLine ("Boat move forward");
}
public void MoveBack()
{
Console.WriteLine ("Boat move back");
}
}