Wei Zhu

A .Net Developer in Australia

WPF: How to Create Command in Step by Step

clock January 28, 2010 19:55 by author Wei Zhu

There are the steps I used to create command and attach command in WPF application. I used WPF Composite as my framework to create WPF application. In the main Shell application's navigation Panel, I attach the command to each button.

1. Definition:

   In the static class : appcommands
  

       public static RoutedUICommand ProductSearchRequestCommand { get; private set; }

2. create instance

        private static void InitializeCommands()
        {
            ProductSearchRequestCommand = new RoutedUICommand();
        }

3. Event handler enabling or disabling command execution
   in the main Module class

        private void ProductSearchRequestCommand_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = true;
            e.Handled = true;
        }

4.Command Event handler in the main module class. Here we will execute business logic
        private void ProductSearchRequestCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {

            regionManager.RegisterViewWithRegion(RegionNames.SearchRegion, typeof(ProductSearchCriteriaView));
            regionManager.RegisterViewWithRegion(RegionNames.MainRegion, typeof(ProductSearchResultsView));
        }

5.Creat in application's command binding, we attach it to the application's command binding.

            CommandBinding binding = new CommandBinding(
                            AppCommands.ProductSearchRequestCommand,
                            ProductSearchRequestCommand_Executed,
                             ProductSearchRequestCommand_CanExecute);
            Application.Current.MainWindow.CommandBindings.Add(binding);

6. Attach the command to screen. In the XAML file.
        <Button Content="Search Product"
            Command="local:AppCommands.ProductSearchRequestCommand"
               VerticalAlignment="Top" Height="23.463">
        </Button>

 Once you set up the first command. It should be easy to creat the left.



First Version Jquery plugin at asp.net mvc

clock October 26, 2009 19:36 by author Wei Zhu

In the first asp.net mvc with Jquery plugin I implement 3 JQuery plug in

Simple Model: see link http://www.ericmmartin.com/projects/  

         I  implement 3 types of simple model here. Especially for Contact simple model, it need asp.net mvc provide ajax method.

Month Calendar:  see link http://www.bytecyclist.com/projects/jmonthcalendar

week calendar: see link http://www.redredred.com.au/new-jquery-weekly-calendar-plugin/

you can download source code from the source code of http://juqerymvc.codeplex.com/  . Once you download, you can open it by visual studio 2008, and then start the fun.



Welcome to My blog

clock October 14, 2009 07:05 by author Wei Zhu

Welcome to my website, My website is basd on .net technology.  You will see how I use or learn asp.net mvc architecture and WPF.

I will post a different version of asp.net mvc project in codeplex and help you go through them easily.

 



RecentPosts

Sign in