WPF related articles on MSDN magazine of Feb 2009

WPF Apps With The Model-View-ViewModel Design Pattern http://msdn.microsoft.com/en-us/magazine/dd419663.aspx written by Josh Smith. He has written lots of articles on WPF. You can view them at his blog joshsmithonwpf.wordpress.com     Writing More Efficient ItemsControls http://msdn.microsoft.com/en-us/magazine/dd483292.aspx from Charles Petzold


DependencyProperty Precedence(4)

If you want to know that where the value of DependencyProperty comes from, there is a class called DependencyPropertyHelper. 1: public static class DependencyPropertyHelper 2: { 3: // Methods 4: public static ValueSource GetValueSource(DependencyObject dependencyObject, DependencyProperty dependencyProperty); 5: } It just has one static method called GetValueSource and the parameters is dependencyObject instance and dependencyProperty…


DependencyProperty Precedence(3)

Let’s focused on the coercion of DP value. In the precedence list, the coercion source is the highest. In order to verify it, I have created a class called CoercionButton. 1: public class CoercionButton : Button 2: { 3: static CoercionButton() 4: { 5: WidthProperty.OverrideMetadata(typeof(CoercionButton), new FrameworkPropertyMetadata(null, OnCoerceValueCallback)); 6: } 7:  8: // public delegate…


DependencyProperty Precedence(1)

You know that value of DependencyProperty may come from different sources and all there sources has some priority. In this blog, I focus on the precedence list when calculating the value of DependencyProperty. Highest precedence is listed first: From msdn: http://msdn.microsoft.com/en-us/library/ms743230.aspx   1 Property system coercion 2 Active animations or animations with a Hold behavior…


x:Shared Attribute in xaml (3)

If want to share Image in ResourceDictionary, there is another way except using x:Shared=”false”. <Application.Resources> <BitmapImage x:Key="bitmapImage" UriSource="pack://application:,,,/Resource/Dock.JPG"/> <DataTemplate x:Key="dataTemplate" x:Shared="false"> <Border Background="Blue" Margin="10"> <Image Source="{StaticResource bitmapImage}"/> </Border> </DataTemplate> </Application.Resources> Instead of creating Image as resource, create BitmapImage as resource and use as the Source of Image in DataTemplate. Comparing it with using x:Shared=”false”, it…


x:Shared Attribute in xaml (1)

I have created a simple wpf application. In App.xaml, I defined two resources: one is an Image control(key is image") and another is a DataTemplate which using DynamicResource to reference the Image. <Application.Resources> <Image x:Key="image" Source="Resource\Dock.jpg"/> <DataTemplate x:Key="dataTemplate" x:Shared="false"> <Border Background="Blue" Margin="10"> <ContentControl Content="{StaticResource image}"/> </Border> </DataTemplate> </Application.Resources> And then in Window1.xaml file, I put…


Retained Mode Graphics in WPF

One of the keys to understanding the role of the Visual object is to understand the difference between immediate mode and retained mode graphics systems. A standard Win32 application based on GDI or GDI+ uses an immediate mode graphics system. This means that the application is responsible for repainting the portion of the client area…


Reading WPF Source Code series(1) – DispatcherSynchronizationContext

WPF requires STA threading. One of the changes to the threading support that shipped in the .Net Framework 2.0 was the introduction of SynchronizationContext. The purpose of this class is to provide a model to make communication between threads easier and more robust. I find that there is a great article on codeproject discussion about…


Reading WPF Source Code series(0)

Since the dotnet source code are avaible now, including WPF, it’s a good chance for us to read the code and go deep. So, I will write a series of article descring something found in the code. You can get more information on how to get the source code at: http://blogs.msdn.com/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code.aspx And there is a…