Zhanbo Sun [MS]

Realize .NET & Windows Vista Potential

April 2005 - Posts

  • Bill Gates Keynote from WinHEC 2005

    In his keynote presentation (April 25th, 2005), Microsoft Chairman and Chief Software Architect Bill Gates reflects upon the hardware industry over the last 20 years and how the introduction of 64-bit and multicore computing will create a wave of industry innovation. Gates also provides a view into the foundation being laid for the release of Microsoft Windows "Longhorn."

    The on-demand webcast links are posted at http://www.microsoft.com/events/executives/billgates.mspx

    PostTypeIcon
    2,800 Views
  • WinHEC 2005 Starts

    The annual Microsoft conference on computer hardware and drivers, WinHEC 2005 starts today. It also hosts the launch event for Windows x64. (More highlights.) Of course, many people are very interested in previewing latest longhorn build. Attendants received Longhorn build 5048

    In today’s Wall Street Journal article, Microsoft Puts Early Spotlight On Next Windows Version, it discusses almost exclusively on UI improvement in Longhorn. Of course, Longhorn has much more to offer to be “touted as the most significant product upgrade since Windows 95 a decade ago” (from WSJ article paragraph 16). Just take a moment to open WinHEC 2005 sessions and search for longhorn. 

    And if you also search for Avalon, you can find two relevant sessions: Avalon Imaging Codec Architecture, and Advances in Display and Composition Architecture for Windows. Not too many sessions in WinHEC. Wait until PDC 2005 for much more Avalon coverage. 

    I end this post with a question for my reader. The Wall Street Journal article says “The interface enhancements, based on an underlying technology called Avalon, are designed to give users more immediate visual cues about the nature and number of files they have.” (Paragraph 8) Do you see anything inaccurate here?

    PostTypeIcon
    2,448 Views
  • DockPanel.DockProperty, of type DependencyProperty, is a CLR field

    In Avalon property system, DockPanel.DockProperty is an instance of DependencyProperty. DependencyProperty is a CLR class, and DockProperty is a CLR field defined within DockPanel class:

    .field public static initonly [WindowsBase]System.Windows.DependencyProperty DockProperty

    To be accurate, DockProperty is a public static read-only field. Because it is public and static, any code can access it via DockPanel.DockProperty. Because it is read-only, no code can change its value (to be another DependencyProperty instance, or null) after it is initialized within static constructor. 

    Being a read-only field does not make DockProperty a read-only Dependency Property. My discussion about read-only dependency property appears in the next blog. 

    In brief, DockPanel.DockProperty is

    Within Avalon Property System

        An attached read-write dependency property

    Within CLR

        A public static read-only field


     I end this post with a question for my reader. There is another DependencyProperty defined/owned by DockPanel: LastChildFillProperty. Does the table above apply to it as well?

    (This posting is provided "AS IS" with no warranties, and confers no rights.)

    PostTypeIcon
    3,124 Views
  • Locally set value takes precedence over Style value

    (Note: Whoever has a better tool to post code into this blog system please contact me. )

    If a DependencyProperty’s value is locally set, this value takes precedence over whatever value specified in Style. For example, the only button’s Background is LightGreen instead of LightBlue:

    Read more, at http://blogs.msdn.com/zhanbos/archive/2005/04/22/410683.aspx.

    PostTypeIcon
    2,536 Views
  • FrameworkPropertyMetadata.Inherits

    Filed under:

    FrameworkPropertyMetadata.Inherits indicates whether the DependencyProperty registered with this metadata is inheritable or not. For example, Binding.DataContextProperty is inheritable, yet DockPanel.DockProperty is not.

    The demo code below firstly creates a DockPanel, a StackPanel, and a Button. To differentiate between getting a value from inheritance and getting the default value, we then set DockProperty value for stackPanel1 to be Dock.Top. We also set DataContextProperty for stackPanel1 to be dockPanel1. (Default values for DockProperty and DataContextProperty are Dock.Left and null respectively.)

    Before and after we add button1 into tree, we print out its values for DockProperty and DataContextProperty. It clearly shows the effect of property inheritance. 

    You can put all the code inside Click event handler for a button.

        // Sample event handler: 
        private void ButtonClick(object sender, RoutedEventArgs e)
        {
          DockPanel dockpanel1 = new DockPanel();
          StackPanel stackPanel1 = new StackPanel();
          Button button1 = new Button();

          DockPanel.SetDock(stackPanel1, Dock.Top);
          Binding.SetDataContext(stackPanel1, dockpanel1);

          System.Diagnostics.Debug.WriteLine("button1.DockProperty is " + DockPanel.GetDock(button1).ToString());
          object value1 = Binding.GetDataContext(button1);
          System.Diagnostics.Debug.WriteLine("button1.DataContextProperty is " + (value1==null?"null":value1.ToString()));
       
       
      dockpanel1.Children.Add(stackPanel1);
          stackPanel1.Children.Add(button1);

          System.Diagnostics.Debug.WriteLine("button1.DockProperty is " + DockPanel.GetDock(button1).ToString());
          value1 = Binding.GetDataContext(button1);
          System.Diagnostics.Debug.WriteLine("button1.DataContextProperty is " + (value1 == null ? "null" : value1.ToString()));
        }

    The output is as follows:
    button1.DockProperty is Left
    button1.DataContextProperty is null
    button1.DockProperty is Left
    button1.DataContextProperty is System.Windows.Controls.DockPanel

    There are various other ways to affect a DependencyProeprty’s value. More blogs to come.

    (This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm)

    PostTypeIcon
    2,687 Views
  • Visual Studio 2005 Shortcut Keys

    The more you play with March 2005 CTP with VS2005, the more likely you will pick up new shortcut keys to speed up your programming. Here are just five of them (for Visual C# projects):

    1. Ctrl+K, Ctrk+X: Insert Snippet
    2. Ctrl+K, Ctrl+S: Surround With
    3. Ctrl+R, Ctrl+R: Rename (One commonly used Refactor operations)
    4. Ctrl+Alt+↓(the down arrow key): Show Active files dropdown menu
    5. Ctrl+Tab: Show active files and tool windows for easy navigation among them

    There are plentifully more and they are subject to change. Of course, many existing shortcut keys in VS.NET 2002/2003 should continue to work in VS2005. For example, pressing Ctrl+Alt+O gives focus to Output window. In future code snippets where System.Diagnostics.Debug.WriteLine()gets used, you can see the result in Output window. 
     (This posting is provided "AS IS" with no warranties, and confers no rights.)

    PostTypeIcon
    6,950 Views
  • What’s New in Avalon March 2005 CTP

    For people who are following WinFX in general and Avalon in particular, this MSDN technical article is very informative: Introducing the March 2005 CTP: What's New in "Avalon". It provides two sample projects you can download and play with while you are reading it. 

    One correction though: We do not have Parser.LoadXAML() method. It should be Parser.LoadXml(). This method is not new in March CTP, but the removal of loose XAML activation support is.

    (This posting is provided "AS IS" with no warranties, and confers no rights.)

    PostTypeIcon
    2,985 Views
  • CLR Event vs. Routed Event: Two Demo Applications

    Because it is extremely difficult to paste code snippet into longhornblogs' new rich text editor, I have to move the bulk of my post into msdn blogs.

    As you may have already known, you can define and use Dependency Property as well as CLR Property in Avalon. (If you want to know more about Avalon’s property system, stay tuned in this blog.) Same thing can be said about CLR Event and Routed Event. By supporting routed event in Avalon, the parent element can participate in events sourcing from its child elements. This blog post presents two applications to show the differences between CLR event and RoutedEvent.

     

    Complete post at http://blogs.msdn.com/zhanbos/archive/2005/04/02/404901.aspx

    PostTypeIcon
    2,473 Views