Steveluo’s Blog

Just another WordPress.com weblog

Archive for the ‘WPF’ Category

WPF Resources — open source

Posted by steveluo on March 13, 2009

2D/3D Chart :
  visifire

Posted in WPF | Leave a Comment »

MVVM: How to

Posted by steveluo on March 1, 2009

I have learned the following best practices from thess great articles.

Karl Shifflet and Adam Kinney talk about ViewModel on Channel9: http://channel9.msdn.com/shows/Continuum/MVVM/

  • Jeff Handley has a number of great post on ViewModel: http://blog.jeffhandley.com/archive/2008/10/21/viewmodel-pattern.aspx[1]Introduction to Model/View/ViewModel pattern for building WPF apps  by John Grossman
    [2]Patttern MVVM  by Josh Smith
    [3]The ViewModel Pattern by David Hill
    [4]http://www.lab49.com/files/videos/Jason%20Dolinger%20MVVM.wmv 

    1)  How to lay out Xaml files
        
    2) Relay Command
    3) Treeview’ double click  — 
    4) Datagrid  binding
    5) Flat to tree list
  • Posted in WPF | Tagged: | Leave a Comment »

    attached property

    Posted by steveluo on February 24, 2009

     

    treeview double click binding:
    1: http://blogs.msdn.com/johngossman/
    2 http://groups.google.com/group/wpf-disciples/browse_thread/thread/63cbe8b2b0575e4e?pli=1
    3: http://marlongrech.wordpress.com/2008/12/13/attachedcommandbehavior-v2-aka-acb/
      a smart way to use double click …

    private static void OnMouseDoubleClickCommandChanged(DependencyObject target, DependencyPropertyChangedEventArgs e)
    {
               UIElement element = target as UIElement; if (element != null)
              {
                           
    if ((e.OldValue == null) && (e.NewValue != null))
                           {  
                                       element.AddHandler(
    UIElement.MouseDownEvent, new MouseButtonEventHandler(UIElementMouseLeftButtonDown), true);
                                       
    //element.MouseLeftButtonDown += UIElementMouseLeftButtonDown;
                           
    }
                          
    else if ((e.OldValue != null) && (e.NewValue == null))
                           {
                                        element.RemoveHandler(
    UIElement.MouseDownEvent, new MouseButtonEventHandler(UIElementMouseLeftButtonDown));
                                       /
    /element.MouseLeftButtonDown -= UIElementMouseLeftButtonDown;
                          
    }
               }

      
    private static void UIElementMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
                 // gets the sender is UIElement and check ClickCount because we want double click only

     

    }
    and

                  UIElement target = sender as UIElement;
                 
    if (target != null && e.ClickCount > 1)
                  {
            
                     ICommand iCommand = (ICommand)target.GetValue(MouseDoubleClickCommandProperty);
                           
    if (iCommand != null)
                           {  
                                     
    RoutedCommand routedCommand = iCommand as RoutedCommand;
                                   
    // check if the command has a parameter using the MouseEventParameterProperty         
                                   
    object parameter = target.GetValue(MouseEventParameterProperty);

                                   // execute the command
                                 
    if (parameter == null)
                                 {       parameter = target;
                                 }

                                 if (routedCommand != null)
                                 {
                                         routedCommand.Execute(parameter, target);
                                    }
                                 else
                                {
                                       iCommand.Execute(parameter);                              }

     

                                      e.Handled =  true;

     

                          }

    }

    }

     

    Posted in WPF | Leave a Comment »

    WPF Resources

    Posted by steveluo on February 23, 2009

     

      FAQ http://wpfwiki.com/
    MSDN FAQ
    Syncfusion FAQ
     Best WPF forums MSDN’s WPF forums
    stackoverflow
    Expression Blend forums to help style your WPF Apps
     Best WPF articles 1) xmal
    2) data binding
         Data Binding Overview (MSDN)
         Windows Presentation Foundation Data Binding Part1
         Windows Presentation Foundation Data Binding: Part 2
         Flexible and Powerful Data Binding with WPF ( CoDe : part1, part2 )
    3) Treeview 
         WPF treeviews on LINQ to SQL  
         LINQ AsHierarchy() extension method  part1 part2
    4)  MVVM Pattern & CAL
          WPF Apps With The Model-View-ViewModel Design Pattern

    5)
     
    Best WPF blogs *Beatriz Costa – WPF Data Binding
    Charles Petzold’s WPF book blog
    Fil Fortes
    *john gossman   — An architect of WPF 
    *Josh Smith
    Karsten Januszewski
    Kevin Moore’s Okoboji
    Lester Lobo
    Marcelo Lopez Ruiz
    Rich Application (e.g. US map in listBox)
    Rob Relyea
    Tim Sneath
    Windows Presentation Foundation SDK
    The WPF blog by Lee Brimelow (no longer blogging about WPF)
     Best WPF tutorials  MSDN .Net 3.5 WPF
    ContentPresenter.com’s WPF tutorials – Lots of video tutorials, all WPF
    WPF: A Beginner’s Guide 1, 2, 3, 4, 5, 6
    A Guided Tour of WPF
     Best examples  1)  CodeProject
     2)  Chart: 
     Best Miscellaneous WPF resources The Application Portfolio on Channel9’s WPF Wiki
    The 3rd party controls list on Channel9’s WPF Wiki
    wpf-resources.com – An extension of resources provided on Channel9
    http://www.expressionblend.com/ – Expression Blend help for WPF application developers
    http://www.wpfpedia.com/ – A categorized WPF resource guide.
    http://www.wpfplex.com/ – Yet another categorized WPF resource guide
         CheatSheet XAML for WPF Cheat Sheet 1.0
    WPF XAML Data Binding Cheat Sheet
    2008 WPF Boot Camp
    WPF Disciples
       

    Posted in WPF | Leave a Comment »

    the relationship among WPF properties

    Posted by steveluo on February 23, 2009

    Properties ( CLR properties),  DependencyProperty and  Attached properties (Attached  DependencyProperty)
    Attached properties are typically defined as a specialized form of dependency property that does not have the conventional property “wrapper”. (src)

    a DependencyProperty is a special form of property that has the feature of being able to interact with WPF (styling, data binding, animation, etc.).

    A DependencyProperty is always a property of an object derived from the DependencyObject class. Note that only Dependency Properties can be used as a binding target. A DependencyProperty is created using the static Register method of the DependencyProperty class.

    Common Language Runtime (CLR) property is: it is the classic .NET class property.

    an Attached DependencyProperty should be stored in a public static readonly field. This is to ensure its visibility to anyone wishing to use it.

    from  Attached Properties Overview,

    Posted in WPF | Leave a Comment »