Notes on WPF Changes
from Sept 2005 (PDC) CTP
to November 2005 CTP
The November 2005 Community Technology Preview (CTP) build
of WinFX contains numerous API changes from the September 2005 CTP (the PDC ’05
build). While the basic design and principles discussed in Programming
Windows Presentation Foundation: Beta Edition are unchanged, some of the
details are different from our
last list of changes (from beta 1 to the September 2005 CTP).
You’ll also want to check out Microsoft’s Introducing
the November CTP: What’s New In Windows Presentation Foundation.
General
- <ApplicationDefinition Include="MyApp.xaml"
/> is all you need in your .proj (or .csproj or .vbproj) file to make
MyApp.xaml build with your project, i.e. no need to add it as a “page” ala
<Page Include="MyApp.xaml" />. In fact, if you do, msbuild
will try to compile it into the project twice and you’d have a compiler
error.
- The mini-languages have been removed, e.g. the following
in the Sept CTP:
<!-- Sept CTP -->
<Style ... >
<Setter Property="Background"
Value="VerticalGradient White LightGray" />
</Style>
Is now the following in the Nov CTP:
<!-- Nov CTP -->
<Style ... >
<Setter Property="Background">
<Setter.Value>
<LinearGradientBrush>
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0" Color="White" />
<GradientStop Offset="1" Color="LightGray" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Style>
Note that this does not change the programming model – it is just a syntax
change. These mini languages were simply a shorthand for the fully-specified
syntax.
- There’s no longer a need to put a UICulture element into
your .csproj if you’ve got a mapping PI in your project just to get it to
compile, i.e. the following is no longer needed:
<Project DefaultTargets="Build" ...>
<PropertyGroup>
<RootNamespace>AvCalc</RootNamespace>
<AssemblyName>AvCalc</AssemblyName>
<OutputType>winexe</OutputType>
<!-- no longer needed to compile in the presence of a mapping PI
-->
<!--<UICulture>en-US</UICulture>-->
...
</PropertyGroup>
...
</Project>
In fact, if you’ve got the UICulture element hard-coded in your .csproj
and you try to compile in another locale, you’ll have problems.
Layout
- The RotateTransform ctor in the Sept CTP:
RotateTransform(double angle, Point
center)
has been replaced with the following in the Nov CTP:
RotateTransform(double angle, double
centerX, double centerY)
- The LayoutTransform property remains, but this used to
offer one of the mini-languages mentioned in the ‘General’ section of this
document. It was previously possible to use strings such as ‘scale 2’ or
‘rotate 20’ in XAML for this property. Now it is necessary to spell out
transformations in full.
- The Superscript and Subscript text inline elements have
been removed. Instead, use a Span element, setting the Typography.Variants
attached property to Superscript or Subscript.
Controls
- The Window.Text property has been renamed Window.Title
- Menu separators are now created with a <Separator>
element instead of using a MenuItem with Mode="Separator"
Data Binding
- ObjectDataProvider: Instead of the TypeName parameter
which took a type name differently than any other place in WPF, i.e.
“Namespace.Class,Assembly”, the parameter is now named ObjectType and uses
the Type XAML namespace extension, so code in the Sept. CTP:
<!-- Sept, CTP -->
<ObjectDataProvider TypeName="PersonBinding.RemotePeopleLoader,PersonBinding" ... />
now looks like this in the Nov, CTP:
<!-- Nov, CTP -->
<?Mapping XmlNamespace="local"
ClrNamespace="PersonBinding" ?>
<Window xmlns:sys="sys" ...>
<ObjectDataProvider
ObjectType="{x:Type
local:RemotePeopleLoader}" ... />
...
</Window>
- ObjectDataProvider: Instead of a comma-delimited last of string
parameters, the ODP requires you to populate a collection of typed ctor
parameters:
<!-- Sept, CTP -->
<ObjectDataProvider Parameters="foo, 452" ... />
<!-- Nov, CTP -->
<ObjectDataProvider ...>
<ObjectDataProvider.ConstructorParameters>
<sys:String>foo</sys:String>
<sys:Int32>452</sys:Int32>
</ObjectDataProvider.ConstructorParameters>
</ObjectDataProvider>
Resources
- The DictionaryLocation enumeration has been renamed ResourceDictionaryLocation.
- Referencing resource files relative to the installed
directory of the application now requires the use of a special form of
URL: the ‘pack’ scheme. For example, to refer to a “foo.jpg” file, you
must use “pack://siteoforigin:,,,/foo.jpg”
Graphics
- Mini-languages (as mentioned in the ‘General’ section of
this document) were widely used in graphics, so although the programming
model has changed, this has a significant impact on using XAML to
represent graphics. In particular, linear and radial gradients, image
references, and transforms must now be specified in full. (Note that
Paths and Polylines retain their mini-languages
- Viewport3D no longer has a Models property. It has a
Children property instead, although you do not need to specify this
explicitly in XAML – just putting elements inside a Viewport3D adds them
as Children by default. You must add one or more ModelVisual3D elements as
Children – this is a new type. It in turn has a Content property that
contains instances of Model3D (or derived types). Model3D is what you used
to add to Viewport3D.Models, so this adds another layer to the hierarchy
you need to create for 3D content. (This change is primarily to improve
the extensibility of the 3D API.)
Animation
- The DictionaryLocation enumeration has been renamed ResourceDictionaryLocation.
- Property-based triggers (i.e. <Trigger> as opposed
to <EventTrigger>) can now launch actions – previously they could
only set properties. Actions can be launched either when the trigger goes
from being inactive to active (<Trigger.EnterActions>) and when it
goes from being active to inactive (<Trigger.ExitActions>). Note
that while data triggers can now run actions as well as properties,
<EventTriggers> can only launch actions – they cannot set
properties. (This is because event triggers are by their nature
instantaneous – it wouldn’t be useful for an event trigger to be able to
set a property like a data trigger can, because an event trigger has no
duration; the property would only be set for 0 seconds which wouldn’t be
terribly useful…)
-
Interop
- WindowsFormsIntegration.dll has moved to the C:\Program
Files\Reference Assemblies\Microsoft\WPF\v3.0 folder.