26
Index Symbols & Number @ (at symbol) for attribute references, 707 {} (curly brackets), 526 14-15 Puzzle, 135–139 A AccelerationRatio attribute, 908 accelerator keyboard events, 304–307 affine transforms, 838 alignment content within buttons, 68 Ellipse class, for, 58 formatting text ToolBar, 337–339 horizontal. See HorizontalAlignment property StackPanels, buttons within, 92 vertical. See VerticalAlignment property Angle property, animating, 909, 931–933 animation AccelerationRation attribute, 908 Animatable abstract class, 791, 819, 861 AnimationBase abstract classes, 861 AnimationClock type, 863, 889 AnimationTimeline abstract class, 861, 863 arbitrary paths, 929 By attribute, 869 AutoReverse property, 869, 892–893 BeginAnimation method, 863 BeginTime attribute, 871, 873–874 ColorAnimation class, 875–876 CreateClock method, 863 cross-element triggering, 875–876 CutoffTime attribute, 871 DecelerationRation attribute, 908 delaying after events, 871 dependency properties, 860–861, 863 DispatcherTimer for, 859–860 DoubleAnimations. See DoubleAnimation class durations. See durations, animation Forever RepeatBehavior, 870, 892 HandoffBehavior property, 877–878 iteration, 870 key-frames. See key-frame animations MatrixAnimationUsingPath class, 929 multiple animation support, 871–872 ParallelTimeline elements, 873–875 Path animation. See Path animation classes PathGeometry property, 929 PointAnimation, 887, 929–930 From property, 863 To property, 863–869 From property, 868–869 To property, 868–869 RepeatBehavior attribute, 870, 873 repetitious markup issues, 876 retained graphics system, 860 smoothing, 892–893 SpeedRatio property, 873 Spline<Type>KeyFrame classes, 919–926 start criteria, 863–864 storyboards for. See storyboards StringAnimationUsingKeyFrames, 918 Styles with. See styles, animation of targets, 866–867 Timeline abstract class, 861 timers, basing on, 859–860 TimeSpan objects, 862 transforms, of. See transforms, animating triggers for, 864, 866, 868 Application objects allowed number of, 6 creating, 3 events defined for, 8 inheriting, 8–10 MainWindows property, 10–11 obtaining, ways for, 8 OnStartup method, 8–10 overriding methods, 8–10 Run method, 4, 6, 12 SessionEnding event, 8, 10 ShutdownMode property, 12–13 Windows property, 11–12 XAML files for defining, 479–480 ApplicationCommands class, 73–76, 308–311, 317, 422–425 arcs, 792, 794–797, 813 ArrangeOverride method Arrange method calls, 207 calls to, 204 custom panel implementation, 235, 237, 246, 254, 255 LayoutTransform property with, 831 overriding for child elements, 203–204 purpose of, 209–210 return value of, 210 sizeFinal.Width calculation, 209 assembly resources, 71, 523–524 977

Applications = Code + Markup: A Guide to the Microsoft ... · XAML files for defining, 479–480 ApplicationCommands class, 73–76, 308–311, 317, ... A Guide to the Microsoft®

Embed Size (px)

Citation preview

Index

Symbols & Number @ (at symbol) for attribute references, 707{} (curly brackets), 52614-15 Puzzle, 135–139

A AccelerationRatio attribute, 908accelerator keyboard events, 304–307affine transforms, 838alignment

content within buttons, 68Ellipse class, for, 58formatting text ToolBar, 337–339horizontal. See HorizontalAlignment propertyStackPanels, buttons within, 92vertical. See VerticalAlignment property

Angle property, animating, 909, 931–933 animation

AccelerationRation attribute, 908Animatable abstract class, 791, 819, 861AnimationBase abstract classes, 861AnimationClock type, 863, 889AnimationTimeline abstract class, 861, 863arbitrary paths, 929By attribute, 869AutoReverse property, 869, 892–893BeginAnimation method, 863BeginTime attribute, 871, 873–874ColorAnimation class, 875–876CreateClock method, 863cross-element triggering, 875–876CutoffTime attribute, 871DecelerationRation attribute, 908delaying after events, 871dependency properties, 860–861, 863DispatcherTimer for, 859–860DoubleAnimations. See DoubleAnimation classdurations. See durations, animationForever RepeatBehavior, 870, 892HandoffBehavior property, 877–878iteration, 870key-frames. See key-frame animationsMatrixAnimationUsingPath class, 929multiple animation support, 871–872ParallelTimeline elements, 873–875Path animation. See Path animation classesPathGeometry property, 929PointAnimation, 887, 929–930

From property, 863To property, 863–869From property, 868–869To property, 868–869RepeatBehavior attribute, 870, 873repetitious markup issues, 876retained graphics system, 860smoothing, 892–893SpeedRatio property, 873Spline<Type>KeyFrame classes, 919–926start criteria, 863–864storyboards for. See storyboardsStringAnimationUsingKeyFrames, 918Styles with. See styles, animation oftargets, 866–867Timeline abstract class, 861timers, basing on, 859–860TimeSpan objects, 862transforms, of. See transforms, animatingtriggers for, 864, 866, 868

Application objects allowed number of, 6creating, 3events defined for, 8inheriting, 8–10MainWindows property, 10–11obtaining, ways for, 8OnStartup method, 8–10overriding methods, 8–10Run method, 4, 6, 12SessionEnding event, 8, 10ShutdownMode property, 12–13Windows property, 11–12XAML files for defining, 479–480

ApplicationCommands class, 73–76, 308–311, 317,422–425

arcs, 792, 794–797, 813ArrangeOverride method

Arrange method calls, 207calls to, 204custom panel implementation, 235, 237, 246, 254,

255LayoutTransform property with, 831overriding for child elements, 203–204purpose of, 209–210return value of, 210sizeFinal.Width calculation, 209

assembly resources, 71, 523–524

977

Microsoft Press
Note
Applications = Code + Markup: A Guide to the Microsoft® Windows® Presentation Foundation (ISBN 0-7356-1957-3) by Charles Petzold. Published by Microsoft Press. Copyright © 2006 by Charles Petzold.

978 attached properties

attached properties AffectsParent flags, 241, 242attributes as, 521defined, 154–155dependency properties, compared to, 241DockProperty example, 154–155metadata options, 241XAML syntax, 871

attributes interrogating, 504XAML representations of, 519, 521–522

B Background property of Window

brushes for, 26, 29client areas, setting for, 26default tranparency, 144defined, 22setting with templates, 668–669SolidBrushColor brushes, setting with, 26–27

BAML files, 474–475 BeginStoryboard class

class hierarchy of, 880–881ControllableStoryboardAction classes with, 880–883EnterActions collections, 879ExitActions collections, 879HandoffBehavior property, 877–878multiple animations from, 866Name attribute assignment, 881triggers, 864, 866

Bevel line joins, 774–777 Bézier curves

advantages of, 800–801, 804assumptions for drawing formulas, 804BezierSegment class, 800boundaries of, 804constants defining, 806control points, 798–799convex hulls, 804cubic form, 806end points, 798equations for, 808–809joining, 804–805mathematics of, 806–809multiple joined, 804–805parametric form, 806path mini-language, 812–813PathFigure StartPoint for, 800PathGeometry, defining in, 930–931PolyBezierSegment objects, 804–805quadratic, 811–812, 813required methods for, 792slope at endpoints, 807–808

smooth cubic, 813–814spline nature of, 798. See also splinesSpline<Type>KeyFrame classes, 919–926varieties of, 792

binding BindingNavigator control, 734–735 button commands with event handlers, 74–76 button data to properties, 78–79 class for. See Binding class data. See data binding

Binding class BindingMode enumeration, 607–608button data binding with, 79Converter property, 366, 617–620DataContext with, 610–611ElementName property, 606–607, 627Mode property, 607–610MultiBinding elements, 623–625Path property, 606–607, 615–616quotation marks, placement of, 606–607RelativeSource property, 636–638setting bindings on targets, syntax for, 606–607Source property, 607, 630syntax for, 607UpdateSourceTrigger property, 626–627

BitmapImage class, 53–54, 56, 940–941 bitmaps. See also Image class

array arguments for, 946BitmapSource class, 939–940, 945bits, creating from, 945buttons from, 71–73creating, 942–947cropping, 948, 954dimensions of objects, determining, 962DrawingContexts for. See DrawingContext classDrawingGroups. See DrawingGroup classelements, displaying in, 943–945file types supported, 940Palette property, 940, 945parameterless constuctors for, 941pixel formats, 940, 942, 945RenderTargetBitmap class, 942–943Rotation property, 941saving, 942size issues, 945, 962Source property, setting to Uri, 941Stretch property, 943stride arguments, 945–946transforming, 948Viewport property, 963–965

bolding text, 60, 61–62, 329–331 BookReader application, 592–598

Canvas class 979

borders Border class, 135BorderBrush property, 42BorderThickness property, 42content, around, 48GradientBrush class with, 42–43suppressing sizing borders, 48

Brush type Background property of Window, 22BorderBrush property, 42BorderThickness property, 42BrushConverter class, 507BrushMappingMode property, 33Changed event, 29class hierarchy for, 26, 958DrawingBrush class, 960Foreground property, 43Freezable class, 29gradient brushes. See gradient brushes;

LinearGradientBrush classImageBrushes. See images, ImageBrush classlinear gradients. See LinearGradientBrush classmultiple color gradients, 37radial gradient brushes. See RadialGradientBrush

classShape class properties, 760solid brushes in XAML, 507SolidBrushColor brushes, 26–31text color, 48TileBrush-derived classes, 958types of graphics allowed with, 939VisualBrush class, 959XAML with, 507, 508–509, 539–541

Brushes type, 29bubbling events, 165, 168Button class

aligning content, 68Background (color) property, 70–71binding, 74–76, 78–79bitmaps for, 71–73ButtonBase. See ButtonBase classButtonChrome class, 143, 165, 219Canvas objects as content for, 133check boxes. See CheckBox controlsClip property, 814color, changing, 67, 70–71Command property, 73–76Content property of, 66–67ContentTemplate elements, 680controls, as a kind of. See controlsDataContext property, 78defined, 65derived classes, 76Focus method, 67font settings, 70

Foreground (color) property, 70–71Height property, 69HorizontalAlignment property, 68–69images for, 71–73input focus, 67keyboard shortcuts for, 67Margin property, 68multiple objects in content, 98Name property, 93Padding property, 68panels, holding in, 90radio buttons. See RadioButton controlssetting to Content property of Window, 66sharing formatting properties. See stylessizing buttons, 68–69styles, targetting with, 645Template property of, 663, 666. See also

ControlTemplate class; templatesTextBlock class, binding in templates, 666–667toggle buttons. See ToggleButton classToolTips for, 79–80Triggers section samples, 864, 865–866Uri class to access resources, 72VerticalAlignment property, 68–69visual images of, 959Width property, 69XAML for, 514–515

ButtonBase class, 66–67, 68, 76, 160

C calendars, 693–704 Canvas class

animating properties of, 871–872attached properties, 241Bottom property, 761buttons, as content for, 133Children collection, 180class hierarchy, 89coordinate systems for, 844–846guideline for using, 133Height property, 131isDrawing property, 175–176layering of elements, 131Left property, 760, 761locations of elements, specifying, 131mouse events with, 175–176origin, setting, 844–846overlapping elements, 131printing, 375purpose of, 90, 131RenderTransform, setting, 844–846Right property, 761Shape objects, positioning, 131, 760–761

980 CheckBox controls

Canvas class, continued SizeChanged event, 905sizing elements, 131text placement, 135Top property, 760, 761Width property, 131

CheckBox controls, 76, 77–79, 670Checked event, 77child elements

Arrange method, 203–204, 207Child property, 206–208Children property of Panel, 235five common overrides, 203–204GetVisualChild method, 203, 206Measure method of children, 207, 208–209MeasureOverride method, 203, 206–209OnRender method, 204single-child. See single-child elementssizing of parents, 208–209VisualChildrenCount property, overriding, 203, 206

Class attribute, XAML, 470–471, 472class hierarchy, WPF, 5classes, splitting with partial keyword, 323Click events

ClickMode property, 68of MenuItem, 290routing of, 166–167

client areas, 23, 26–27clipboard commands, 75, 434–441code-behind files, data binding in XAML to replace, 605CollectionView class

arranging views, overview of, 745Can properties, 745constructor, 734currency manager for, 734current position methods, 734events of, 734filtering with, 747–754GetDefaultView method to create, 735grouping with, 754–758IEnumerable implementation, 734index navigation, 734Predicate delegate, 747properties of, 734PropertyChanged events, 746purpose of, 734Refresh method, 746–747sorting, 746

color. See also Color class; Color structure; Color structure; Colors class; Colors class

ColorAnimation class, 875–876, 891, 918–919ColorAnimationUsingKeyFrames, 918DynamicResources for, 539–541system wide change messages, 538–539text, setting for, 48ToolBar example for text, 329–331

Color class Color elements, XAML, 510–512reflection, obtaining members by, 259ToString method results, 263

Color structures, 23–25 Colors class

Color structures in, 263defined, 25reflection, obtaining members by, 259, 265Web browser color support, 25–26

CombinedGeometry class, 787–790 ComboBox controls

default state, 330events of, 330, 331focus issues, 331IsEditable property, 330–331items, populating, 330ToolBar containers of, 330–331user issues, 331

command line arguments, 10Command property of ButtonBase class, 73–76Command property of MenuItem, 290CommandBinding elements, 546–548CommandBindings property of UIElement class, 74–75commands, keyboard, binding to menu items, 308–311console windows, compiler flag control of, 5Content property

borders, 48Button class, setting to, 66–67compositing, importance of, 63ContentControl class, derivation from, 45ContentPresenter elements, 208element sizing issues, 189font settings, 46–47FrameworkElement class, 52Image class, 52notification of events, 51object type of, 45one object limitation issue, 45panels, setting to, 90–91purpose of, 45SizeToContent property, 48string issues, 50–51templates with, 666, 679text string, setting to, 45–46ToString methods with, 48–49UIElement class, 51–52user-input events, 61–62XAML for, 514–516

ContentControl class Button class, relationship to, 66–67ContentPresenter class, 669–670DataTemplate objects with, 679, 683–685HeaderedContentControl class, 100multiple objects in content. See Panel class

custom panels 981

panels. See Panel class purpose of, 45templates for setting content, 677–679

ContentElement class defined, 60event routing, 169IsMouseOver property, 169relation to UIElement, 60styles not supported, 650user-input events, 61–62

ContentPresenter class, 669–670, 677–680, 685ContentProperty, data binding with, 515–516, 607ContextMenu controls, 312–315ControllableStoryboardAction class, 880–883controls

border reactions to mouseovers, 67buttons. See Button classcheck boxes. See CheckBox controlsclass hierarchy for, 65, 223color response to clicks, 67Control class as parent of, 65, 185, 257custom. See custom controlsdata binding of, 78–79. See also data bindingdefined, 65dependency properties, 144derivations of common controls, 257FormattedText constructors with, 195HeaderedContentControl class, 100hierarchical data display. See TreeView controlsItemsControl class, 257–258label controls. See Label classlist boxes. See ListBox controlslist views. See ListView controlslooklessness of, 663namespaces for, 65property overview, 65radio buttons. See RadioButton controlssharing formatting properties of. See stylessingle-child. See single-child elementsStatusBar class, 339–340templates. See ControlTemplate class; templatestext boxes. See RichTextBox controls; TextBox controlstoggle buttons. See ToggleButton classtree views. See TreeView controls

ControlTemplate class button assignments to, 220–223 class hierarchy of, 664ContentPresenter class, 669–670 ContentTemplateSelector property, 685–688 creating, purpose of, 664defaults for, examining, 672–677 defined, 219, 663element creation timing, 220FrameworkElementFactory objects, 219properties, specifying, 219

purpose of, 663resources, defining as, 667Setter objects, 220Styles, combining with, 669TargetType property, 665, 667template creation, 219triggers, 220, 665, 667, 670, 672VisualTree property of, 219

converting formats, 948convex hulls, 804coordinate systems, 844–847cropping bitmaps, 948, 954curly brackets ({}), 526Cursor class, 171curves

ArcSegments. See arcsBézier. See Bézier curvesPolyline objects for, 762–765positioning, 764splines. See Bézier curves; splines

custom controls background colors, 200Control base class for, 185Focusable property, 185images, displaying in, 202Margin property sizing effects, 189single-child. See single-child elementssizing of, 195–199UIElement class child elements for, 243–244

custom elements background colors, 200consumers, reserving size properties for, 188, 190Content property sizing issues, 189Control base class for, 185desired size, 188–189FillProperty, 192–193Focusable property, 185FrameworkElement base class for, 185Grid class sizing issues, 189images, displaying in, 202Margin property, 188–189MeasureOverride method, 188–193natural size, 190single-child. See single-child elementssizing of. See sizing of custom elementsUIElement base class for, 185

custom panels AffectsParent flags, 241, 242alignment issues, 239ArrangeOverride method, 235, 237, 241, 254, 255attached properties with, 239–241Children property of Panel, 235Children property of UIElementCollection, 242–244FrameworkElement-based, 242, 244–246GetVisualChildren handling, 235

982 dashed lines

custom panels, continued InternalChildren property, 235MeasureOverride method, 235, 237, 241, 246,

253–254not inherited from Panel, 242–244OnRender with, 235Panel, advantages of inheriting from, 235RenderTransform, 254SizeToContent effects, 239sizing of elements, 241UniformGrid class, 235–237VisualChildrenCount handling, 235

D dashed lines, 777–780 data binding

Binding class for. See Binding classBindingMode enumeration, 607–608buttons to properties, 78–79conversions of types for, 617–620DataContext property, 610–611defined, 605delayed updating, 625–627dependency properties, 366, 607, 612, 615DependencyObject, 607, 629–630ElementName property of Binding class, 606–607,

627event handlers, replacement of, 605events defined for, 631–632flags, metadata, 615FrameworkPropertyMetadataOptions, 615GetBindingExpression method, 627INotifyPropertyChanged interface, 631IValueConverter, 617Mode property, 607–610multi-bindings, 620–625, 635–636notification mechanisms, 612OneTime mode, 608, 609OneWay mode, 607–608, 609, 612OneWayToSource mode, 608, 609Path property, 615–616purpose of, 605RelativeSource property, 636–638, 652–653SetBinding method, 607setting on targets, 606–607sources, 605, 607, 627–628, 630static property references, 627styles using for Value attributes, 650, 652–653syntax for, 607targets, defined, 605between two controls, 605–606TwoWay mode, 608, 609UpdateSourceTrigger property, 626–627XAML. See XAML data binding

data entry adding objects to collections, 727BindingNavigator control, 734–735classes, creating for, 719–721, 726CollectionChanged events, 727CollectionView class, 734–735, 747–751creating new records, 733data binding of properties for, 721, 723DataContext property as binding source, 723, 741DataTemplate objects with, 741–743DataTrigger tags, 741–743deleting records, 733event handlers for menu items, 739Executed event handlers for, 724file structure, single records, 726filtering views, 745, 747–754forms for, 721–723grouping views, 745, 754–758indexing collections, 727, 730–733, 734INotifyPropertyChanged interface, 719–721ListBoxes for data display, 741–745, 755–756menus for, 723–724navigation, 729, 733, 735null entries for fields, 734ObservableCollection class for, 727–729opening files, 726, 729overview, 719PersonPanel example, 721–723PropertyChanged events, 719–721, 727–729, 746public classes, creating for, 719–721Refresh method, 746–747saving files, 726, 729sorting views, 745–746XmlSerializer with, 729

databases, 727–729, 734–736 DataContext property of FrameworkElement

binding sources, as, 723data entry implementation example, 741serializing, 726source objects, setting for data binding, 610–611

DataFormats class, 88, 324DataTemplate objects

class hierarchy of, 664ContentTemplates, assigning to, 679–680ContentTemplateSelector property, 685–688DataTemplateSelector class, 685–688DataTrigger tags, 707, 715, 741–743DataType property of, 683GridView class with, 663–664HierarchicalDataTemplate, 353, 355, 708, 710ItemTemplate property, 692–693ListBox controls with, 281, 285purpose of, 663, 664SelectTemplate method, 685–688Triggers sections, 688–691, 741–743visual trees of, 680

DataTrigger tags, 707, 715

DoubleAnimation class 983

dates AbbreviatedDaysNames property, 696calculations with, 114–117DateTime type, 536, 632–633, 968DateTimeFormatInfo class, 627–628, 696internationalizing, 258

deceleration in animation, 908Decorator objects, 210–214dependency properties

AffectsMeasure flag, 146–147, 148, 150animation use of, 860–861, 863attached properties, 154–155, 241binding, 146–147class hierarchy for, 147code example for registering, 146–147conventional .NET compared to, 145custom, defining, 148–150data binding notifications, 615data binding properties, backing, 607, 612DefaultMetadata property, 367DefaultUpdateSourceTrigger, 146–147defined, 145defining, 147DependencyObject class, 147–148, 150DependencyProperty type, 145–146, 366, 368–371DockProperty, 154–155element tree example, 143FontSize property of TextBlock class, 141–145FrameworkPropertyMetadata type, 367GetValue methods, 147–148Grid class, effects on layout, 145Inherits flag, 146–147, 148, 150metadata, 146–147, 367multiple ownership of, 152notification advantages, 145–147propagation through objects lacking the property, 144properties subject to, 144PropertyType property, displaying, 367purpose of, 144–145Register method, 146rejection by specification, 144SetDock property of DockPanel, 153–155SetValue methods, 147–148static nature of fields for, 146styles, issues with, 650TypeProperty, 368–369validation, 146–147, 148, 150visual tree propagation of, 144

Deserialize method, 414device independent units, 17, 18dialog boxes

buttons, enabling in, 67Cancel buttons, 379CommonDialog class, 379Enter key with, 379Escape key with, 379

modal, 13modeless, 13OK buttons, 379Owner assignment, 83, 379placement in classes, issues with, 729positioning, 379printing from. See printingpublic properties, defining, 379ResizeMode property, 378ShowDialog method, 13, 83, 379ShowInTaskbar property, 378Text property of, 82title bars, 378ToolWindow style, 82Uri dialogs, 81Window object nature of, 10WindowStartupLocation, 82, 379WindowStyle property, 378

Dictionary class, 307–308 directories

DirectoryInfo class, 103–104, 348, 353–354, 584DirectoryTreeView class, 348–350, 585discovery time minimalization, 345GetDirectories method, 345viewing, 103–105

DispatcherObject, 5, 356–357DispatcherTimer class, 41, 859–860display resolutions, 17–18distribution file formats, 545docking, traditional Windows, 107DockPanel class

alignment, 109Children, adding to, 107class hierarchy, 89control placement, 107creating objects, 107Dock enumeration, 107–108DockProperty, 154–155GetDock method, 108LastChildFill property, 109menus, docking with, 294priority of multiple controls in, 109SetDock property, 107–108, 109, 153–155setting Content to, 107splitters, 111

DoubleAnimation class animation, as basis for, 861BeginAnimation with, 863class hierarchy of, 861CreateClock method, 863Duration structures for, 862IsCumulative property, 870To property, 863From property, 863purpose of, 861Storyboard parents to DoubleAnimation objects,

865–866

984 DoubleAnimationUsingKeyFrames class

DoubleAnimationUsingKeyFrames class DiscreteDoubleKeyFrame class, 910, 912–913,

916–917IsCumulative property, 916LinearDoubleKeyFrame class, 910, 912–913purpose of, 910SplineDoubleKeyFrame class, 910

DoubleAnimationUsingPath class, 930–934DoubleKeyFrame class, 910, 912DrawImage method, 202Drawing class

class hierarchy of, 951dimensions of objects, determining, 962DrawingGroups. See DrawingGroup classGlyphRunDrawing class, 951ImageDrawing class, 952importance of, 957Opacity, 954types of graphics allowed in, 939VideoDrawing class, 952

Drawing Files, XAML, 552–553 DrawingContext class

AnimationClock overloads, 889drawing methods, 956–957OnRender method, as parameter to, 955–956other methods, 957purpose of, 186

DrawingGroup class BitmapEffect property, 954–955class hierarchy of, 951ClipGeometry property, 954dimensions of objects, determining, 962Drawing property for returning, 957objects typically in, 953Opacity property, 954purpose of, 951Transform property, 955

DrawingImage class class hierarchy for, 949Drawing property of, 950ImageDrawing class, 952purpose of, 939, 949

DrawingVisual class child elements with, 224–226class hierarchy of, 223–224DrawingContext type, 375–377event routing, 224GetVisualChild method, 224–226location of visual, 224printing, 375–377purpose of, 957RenderOpen method, 224, 375–377

drop shadows, 848–853

durations, animation CutoffTime attribute, 871default, 868Duration structures, 862Forever option, 868, 892format for, 868percentage values for KeyTime property, 915RepeatBehavior attribute, 870SpeedRatio property, 873Storyboard, effects on multiple objects, 892Timeline type, 863TimeSpan objects, 862total duration, 871

dynamic layout, 89DynamicResource, 538–541

E Edit menu implementation, 328–329, 434–441 element trees

dependency properties, 143routed input events, 157–158Window objects, typical, 208

elements arranging in panels. See custom panelscustom. See custom elementsdefined, 51desired size, 188–189FrameworkElement class, 52natural size, 190single-child. See single-child elements

ellipses alignment of, 58dimensions, setting, 760DrawEllipse method, 62–63, 956–957EllipseGeometry class, 785, 885, 892–893rendering paradigm, 760sizing of, 57–58Stretch member, 58styles with, 651

em sizes, 46–47engraving effect, 849enumerations, 458, 506environment information, 532–533EvenOdd FillRule, 767–771event handlers

AddHandler method, 93–94, 166–167binding button commands to, 74–76data bindings to replace, 605eliminating, advantage of, 270naming conventions, 7PropertyChangedEventHandler, 719–721RoutedEventArgs objects, 93SelectionChanged events, 330

FrameworkElement class 985

sender casting, 93senders, 164–165 source hierarchy issues, 97–98 Window objects, obtaining, 8XAML representations of, 519–520, 522

eventsApplication class, of, 8bubbling events, 165, 168button clicks, 65–66 Changed event of Freezable, 29Checked event, 77Click event routing, 166–167 custom routed event creation, 168–169 data binding, defining for, 631–632 enabled elements issue, 158EventSetter objects of styles, 654–655 EventTrigger class, 656–657, 864, 866, 868, 878Exit event, 8INotifyPropertyChanged interface, 631keyboard event routing, 167–168, 180–183 menu events, 290mouse events. See mice PropertyChanged events, 719–721 purpose of, 6routing. See routed input events SelectionChanged events, 330senders, 164–165 source elements, 158Startup event, 8stylus. See stylus information TextInput events, 181tunneling events, 165, 168visibility issues, 158XAML representations of, 519–520, 522

Expander controls, 596

F file formats for distribution, 545files

file operations of RichTextBox, 324–328 FileSystemInfo class, 103–104 opening for data entry, 726

Fill property, 192–193, 507, 885fill rules, 767–771, 791–794, 812–815FillBehavor property of animation objects, 863, 869,

870filtering, 745–754Find menu implementation, 442–443FlowDocument objects, 500–502, 572, 653–654,

710–717, 711focus, 67, 180–181, 185fonts

Baseline property of FontFamily, 851–852 Button class, controlling for, 70custom, 815–818

defined, 46–47dependency properties, 144dialog boxes for picking, 392–409em sizes, 46–47FontFamily, setting, 46–47, 144, 330FontSize, 46, 47, 60, 141–146, 524–525Fonts.SystemFontFamilies, 400FontStretch dependency, 144FontStyle property, 47, 62, 144FontWeight property, 47, 62, 144italics, 47LineSpacing property, 853listing all available, 400oblique, 47outlines for, geometric, 815–818rasterization, 815setting to static properties, 506styles, setting for, 640tilted text shadows, 853

Foreground property of Brush type ColorAnimationUsingKeyFrames, 918dependency, 144Image class with, 55purpose of, 43setting with templates, 668–669styles, setting for, 640text color, setting, 48TextBlocks with, 60–61

FormattedText type, 193–199, 202, 633, 815forms, data entry, 721–723. See also data entryFrame class

background colors, setting, 571CanGoBack property, 579–580CanGoForward property, 579–580Content property, 567event support, 574GoBack method, 579–580Navigate method, 574, 577–578NavigateUri property, 566NavigationUIVisibility, 575, 577NavigationWindow as holder, 571Next buttons for, 582Page files as Sources for, 571Previous buttons for, 582Source property, 83

FrameworkElement class ApplyTemplate method, 697Control class relationship to, 65custom panels based on, 242, 244–246dependency properties, 144elements, as base class for, 185EventTrigger class, 864FindName property of, 93GetBindingExpression method, 627Image class, 52

986 FrameworkElementFactory objects

FrameworkElement class, continued LayoutTransform property, 819Margin property, 55, 68, 188–189MeasureCore method, 188–189 MeasureOverride method, 188–193 multiple children support, 235overriding OnRender, 62–63 Panel class hierarchy, 89printing, 375purpose of, 52raster and bitmap derived classes, 939RenderTransform, 254Resources property, 524SetBinding method, 78–79, 607shapes. See Shape class Style property of, 640

FrameworkElementFactory objects, 219, 665FrameworkPropertyMetadataOptions, 615FrameworkTemplate abstract class, 664–666Freezable class, 29–31

G Geometry class

ArcSegments. See arcsBuildGeometry method, 815–818class hierarchy of, 783Clip property, 814–815CombinedGeometry. See CombinedGeometry classData property of Path, 783EllipseGeometry class, 785font customization, 815–818GeometryCollection type, 785GeometryGroup class, 785–787LineGeometry class of, 784LineSegment class, 792PathFigure objects, 791–792PathGeometry objects. See PathGeometry classPathSegment objects, 791–792PolyBezierSegment class, 804–805purpose of, 783QuadraticBezierSegment class, 811–812RectangleGeometry class, 784–785specification of objects, 783Transform property of, 843XAML markup for, 783

GeometryDrawing class, 950–954GeometryGroup class, 785–787GlyphRunDrawing class, 951gradient brushes

borders with, 42–43 defined, 31GradientStop class, 895–899 GradientStops property, 37linear. See LinearGradientBrush class MappingMode property, 33

multiple color gradients, 37place in Brush class hierarchy, 26radial. See RadialGradientBrush classXAML representation of, 512–513

graphical shapes Canvas class with, 760Canvas.Left and Top properties, 760capabilities of Shape objects, 760class hierarchy, 759–760composites, constructing, 760curve creation, 762–765ellipses. See ellipsesEvenOdd FillRule, 767–771Fill property, 760fill rules for, 765, 767–771FrameworkElement ancestry of, 759Grid objects for holding, 761line caps, 772–774line joins, 774–777lines. See Line classNonZero FillRule, 767–771panel types suitable for composites, 760paths. See Path classpens for. See Pen classpolygons. See Polygon classpolylines. See Polyline classpositioning lines in Canvas, 761, 764rectangles. See Rectangle classrendering paradigms, 760scaling, 766–767Shapes library, 759–760strokes. See Stroke ClassStyle elements with, 766XAML for property definitions, 772

graphics bitmaps. See bitmapscomposites. See DrawingImage classcoordinate systems for Canvas, 844–846paths, 790retained graphics system, 860Shape classes. See Shape classstyles, setting for, 651–653transforms. See transformsvector. See vector graphics

Grid class class hierarchy, 89ColumnDefinition property, 112–113controls, adding to, 113creating objects of, 111custom element sizing issues, 189dependency property effects on, 145graphical shape composites in, 761GridLength class, 112GridSplitter objects. See GridSplitter classGridUnitType enumeration, 112

ItemTemplate property 987

Height property, 112multiple columns, 113, 119–120multiple row creation, 113purpose of, 111RowDefinition property, 112–113ScrollBars with, 127–130ShowGridLines property, 111sizing rows and columns, 112, 119spanning rows or columns, 119–120splitters. See GridSplitter classUniformGrids. See UniformGrid classXAML representations, 518–519

GridSplitter class, 122–127 GridView class

class definitions for items in, 360–361Columns property, 360DataTemplate objects for, 663–664defined, 360DisplayMemberBinding property, 362GridViewColumn type, 360, 362

GroupBox controls, 100–102 grouping, 745, 754–758

H Help files

Help menu command implementation, 450–451Page elements, 711templates for, 710–717

hierarchical data display. See TreeView controlshorizontal skew, 828HorizontalAlignment property, 55, 68–69, 187–188,

190Hyperlink elements

BookReader example. See BookReader applicationLinkOnRequestNavigate handlers, 565NavigateUri property, 565NavigationWindows for showing, 565–570RequestNavigate event, 565–566TargetName attributes, 594

Iidentity matrices, 839IEnumerable, CollectionView implementation of, 734IList, 734, 735Image class

alignment properties, 55Background property non-existent, 56BitmapImage. See BitmapImage classdisplay size, 54–55DrawingImage class, 553Foreground property non-existent, 56FrameworkElement parent of, 52Height property, 55loading from files, 53

Margin property, 55MeasureOverride method sizing, 190Opacity, 55–56purpose of, 52rotating bitmaps, 56sizing windows to image size, 55Source property of, 940, 941steps for displaying, 53Stretch property, 54–55, 943styles not supported, 650Uri, setting to Source property, 941Width property, 55

images. See also bitmaps; Image class buttons from, 71–73custom elements, using in, 202ImageBrush class, 958–959, 962–965ImageDrawing class, 952ImageSource abstract class, 939–940TreeViewItems with, 346–347XAML Image elements, 486

inheritance, 8–10, 13–17, 14InitializeComponent wizard example, 581Ink Serialized Format (ISF), 550InkCanvas interface

clipboard methods, 560–562EditingMode property, 553–554EraseBy settings, 553EraserShape property, 555, 560event handling for, 180GetSelectedStrokes method, 562IsHighlighter property, 554–555purpose of, 177Selection setting, 553–554Strokes collections. See Stroke classStylusToolDialog, 555, 557–558

Inline class, 59–62, 516input events, routed. See routed input eventsinput focus for buttons, 67ISF (Ink Serialized Format), 550italics, 47, 60, 61–62, 329–331ItemsControl class

class hierarchy, 257–258, 290grouping feature, 758Items property, 258ItemsPanel property, 690–691ItemsPanelTemplates. See ItemsPanelTemplate objectsItemTemplate property, 353, 663, 692–693menu classes derived from, 289panel replacement, 691Template property of, 690–691TreeView controls descended from, 341

ItemsPanelTemplate objects, 663, 664, 693–704ItemTemplate property, 279–281, 354–355, 663–664,

707

988 journals

J-K journals, 570, 580, 586key-frame animations

arbitrary paths, 929Boolean type, 911Char type, 911class hierarchy for, 910ColorAnimationUsingKeyFrames, 918–919DiscreteDoubleKeyFrame class, 910, 912–913DiscretePointKeyFrame class, 913–914Discrete<Type>KeyFrame classes, 910double type. See DoubleAnimationUsingKeyFramesDoubleKeyFrame class, 910, 912element specification order, 912KeyFrames property, 910KeySpline property, 919–926KeyTime property, 912–915Linear/<Type/>KeyFrame classes, 910LinearColorKeyFrame class, 918–919LinearDoubleKeyFrame class, 910, 912–913LinearPointKeyFrame class, 914–915Matrix type, 911Object type, 911Paced KeyTime property, 915percentage values for KeyTime property, 915PointAnimationUsingKeyFrames, 913–914purpose of, 910Spline<Type>KeyFrame classes, 910, 919–926String type, 911, 918table of types for, 911<Type>KeyFrame classes, 910Uniform KeyTime property, 914Value property, 912, 913

keyboard events accelerators, 304–307Focusable property, 180–181GotKeyboardFocus, 181IsKeyboardFocused property, 180Key enumeration, 181KeyboardDevice type, 183KeyDown, 181KeyEventArgs, 181, 305KeyGesture class, 305, 307–308, 311KeyUp, 181Marches method, 305routing of, 167–168Source property with, 181TextInput, 181tunneling, 181

keyboard shortcuts for buttons, 67

L Label class, 80, 536LayoutTransform property

ArrangeOverride calls, 831compared to RenderTransform, 823defined, 819line widths, effect on, 844Matrix, setting directly, 842MeasureOverride calls, 831–832RenderTransform compared to, 831–833, 883–885rules for, 831ScaleTransform with, 827SkewTransform with, 829–830TranslateTransform with, 824translations ignored, 833

lazy loading, 345–346 line caps, 772–774, 778–779 Line class, 761–780 line joins, 774–777 LinearColorKeyFrame class, 918–919 LinearDoubleKeyFrame class, 910, 912–913 LinearGradientBrush class

angle of gradient, 33BrushMappingMode property, 33calculation tricks, 34–35ColorInterpolationMode property, 33components of, 31constructors for, 32, 33EndPoint property, 37freezing, 33GradientStops property, 37horizontal gradients, 33MappingMode property, 33, 35multiple color gradients, 37padding, 33Reflect setting, 33–34SpreadMethod property, 33StartPoint property, 37units for specifying, 32–33updating backgrounds of windows, 37XAML, representing in, 507, 512–513

LinearPointKeyFrame class, 914–915LineGeometry class, 784–785lines, path mini-language representation, 813LineSegment class, 792–793, 797ListBox controls

adding items, 258, 265, 275alignment, centering, 261Background property, binding with, 269–270,

283–284binding selected values, 272Brush objects, storing, 267–269

Measure method 989

class hierarchy for, 258–257components of, 255creating objects, 258Ctrl key with, 261DataTemplate objects with, 281, 285, 353. See also

DataTemplate objectsdeselecting items, 261DisplayMemberPath property, 266elements allowed in, 258filling the ListBox, 258filters, 751–754focus rectangles, 261font size settings, 275grouping data with CollectionView, 754–758GroupStyle property, 758inheritance from, 277–278initializing selection, 261ItemCollection type, 258Items property, 258ItemsControl as parent, 257, 758ItemSource property, 705ItemsPanel property, 279, 284–285ItemsPanelTemplates, 663–664, 693–704ItemsSource property, 258, 265ItemTemplate property, 279–281, 285, 353, 692–693,

707keyboard control of, 261, 284Label controls as items, 272–273ListBoxItem class for, 273–275ListView descendent class. See ListView controlsmultiple item selection, 262panel replacement, 691purpose of, 257RemovedItems property, 275ScrollIntoView method, 261SelectionChanged event, 262, 275SelectionMode property, 262Shape objects in, 270–271sizing, specifying, 261sorting in, 746StackPanel objects in, 275–277, 281templates for. See ItemsPanelTemplateToolTips in, 283ToString methods of objects for items, 263visual trees for, 281

ListCollectionView class, 734–745 ListView controls

adding items to, 362–363Columns collections, 360DataTemplate objects for, 364–366GridView class, 360Items property, 360, 362–363ItemsSource property, 360, 368–369ListBox parent properties, 360

ListViewItem class, 360purpose of, 360sorting items, 363–364View property, 360, 361, 363

local isolated storage, 85local user application data, 414localizing dates with DateTimeFormatInfo, 258logical trees, 143, 206, 212lookless controls, 663

M Main method, 307MainWindows property of Application, 10–11, 12margins

Button class margins, 68custom element sizing effects, 189FrameworkElement Margin property, 68Margin property of Image, 55print settings, 383–385printing settings, 378StackPanels, for, 92–93

markup extensions Binding. See Binding classcurly brackets for, 526DynamicResource, 538–541StaticResource, 524, 525–526, 537StaticResourceExtension class, 526, 528x:Key, 645, 648x:Static. See x:Static markup extensionx:Type, 644–646x:xData, 705

matrices defined, 838identity matrices, 839key-frame animation types, 911LayoutTransform, setting directly, 842M properties, 839–840Matrix structure, 839–840MatrixAnimationUsingPath class, 929, 934–937MatrixTransform class, 842multiplication of, 838non-commutative nature of, 838Offset properties, 839–840RenderTransform, setting directly, 842rotation strings, 848ScaleTransform equivalence, 840–841symbols for, 838Transform class, 840, 841transform formulas, 839transforms without translation, 839TranslateTransform equivalence, 840

Measure method, 207, 208–209, 831

990 MeasureOverride method

MeasureOverride method aspect ratio maintenance, 190Brush thickness with, 192–193button sizing calculation, 199–200calls to, 189, 204child element sizing, 203, 206–207childless elements, 190clipping issues, 194Content set to element, 189custom panel implementation, 235, 237, 246, 254default return value, 190defined, 188–189FormattedText objects with, 199Grid objects as parents, 189HorizontalAlignment effects, 190Image class with, 190infinity exceptions, 190–191LayoutTransform property with, 831–832Margin property with, 189, 200Measure method of children, 207, 208–209MeasureCore, relation to, 188–189MinWidth and MinHeight, effects of setting, 190natural size, indicating, 190overriding, 189Padding property with, 199Pen class thickness with, 192–193purpose of, 188–189sizeAvailable argument, 189, 194, 201–202sizeFinal.Width calculation, 209SizeToContent property with, 189StackPanel objects with, 189Width and Height, effects of setting, 190

menus accelerators, 304–307CanExecute handlers, 308–311Checked events, 290, 294checked items, 290, 294–295, 297–300class hierarchies of, 289, 290Click events, 290, 291, 294command bindings for, 308–311Command property, 290, 308construction overview, 291context menus. See ContextMenu controlscontrols as menu items, 300–302data binding in, 295, 301–302, 308–311Dictionary objects for, 307–308disabling items, 290DockPanel objects for, 294events defined by MenuItem, 290Headers, 289, 289–290, 291, 311Icon property of MenuItem, 290, 300, 302–304IsCheckable property, 290, 294–295IsChecked property, 290, 294–295item types allowed, 290

Items property, 289, 290keyboard input handling, 304–305KeyGesture class, 305, 307–308, 311Marches method for keyboard events, 305Menu elements, 546Menu type, 289, 290, 291MenuItem type, 289, 290, 311, 446mutually exclusive checked items, 295new MenuItem creation, 291OnPreviewKeyDown method overrides, 305, 307RoutedUICommand type, 308–311Separator controls, 290structure of, 289submenus, 289, 290, 300, 302–304Tag property of MenuItem, 297text for, setting, 291, 311toolbars incorporating, 337top-level, 290Unchecked events, 290, 294underline character, 291, 304–305

MessageBox class Show methods, 8methods, overriding, 8–10mice

ButtonState property, 169–170Canvas, events with, 175–176capturing process, 171–172ChangedButton property, 169–170ClickMode property of buttons, 68cursor representation, 171GetPosition method, 169IsMouseOver property, 169left vs. right events, 170LeftButton property, 169MiddleButton property, 169Mouse class static properties, 170–171Mouse events, 169–171MouseButton enumeration, 169–170MouseButtonEventArgs, 169–170MouseButtonState enumeration, 169MouseDown events. See MouseDown eventsOnMouseUp method, 175OnPreviewMouseDown method, 160OnRender method graphical objects, 187pointer location, obtaining, 28Preview events, 160, 169–176RightButton property, 169routed events, 169–176up and down event pairing, 171

Miter line joins, 774–777modal dialog boxes, 13modeless dialog boxes, 13, 437–441monitors, 25mouse. See mice

Panel class 991

MouseDown events ButtonState property for, 169–170coordinates for, 7–8defined, 6event handler example, 6–7handlers for, 7–8MouseDownEvent for, 160OnMouseDown, relationship to, 158overriding OnMouseDown, 15

multi-bindings, 620–625, 635–636

N Name attributes, 697namespaces

ClrNamespace property, 504commonly used by WPF, 3System, associating with XAML, 510–512XAML, 459, 470, 475–476XmlNamespace property, 504XmlnsDefinitionAttribute, 504

navigation applications BookReader. See BookReader applicationbrowser applications. See XAML Browser Applicationsdefined, 545fragment navigation, 596frames. See Frame classNavigationWindows. See NavigationWindow classTabControl class, 596

NavigationWindow class Application.Current property for obtaining, 569Back button, 570CanGo properties, 579–580Content property, 567event support, 574Forward button, 570frames in. See Frame classGetNavigationService method, 569GoBack method, 579–580journal, 570Navigate method, 569, 577–578NavigateUri property, 566NavigationService property of Page for obtaining, 569Next buttons for, 582Page elements, 567–570Previous buttons for, 582purpose of, 565–566RequestNavigate event handler, 569ShowsNavigationUI, 575Source property, 566–567StartupUri attribute, 566, 597Title property of Page, 567visited links journal, 570, 579–580

nesting panels, 94–95NonZero FillRule, 767–771Notepad Clone example, 413–453numeric type converters, 618–619, 622

O oblique text, 47ObservableCollection class, 727–729, 734–735, 746, 754OnMouseDown events, 158–159OnRender method

calls to, 186–187, 204clipping issues, 194, 201–202drawing surface assumptions, 186DrawingContext as parameter for, 955–956DrawText method in, 193–195FormattedText type with, 193–199InvalidateVisual calls, 538–539MeasureOverride method calls, 189mouse event relation to graphical objects, 187overriding, 62–63, 204Pen class thickness with, 192purpose of, 51RenderSize property, 186–187RenderTransform property with, 831retention of graphical objects, 186–187

opacity animating, 893, 917, 933DrawingGroup, setting for, 954

opening files for data entry, 726, 729origins, setting for Canvas, 844–846overriding methods, 8–10, 203–204Owner property of Window objects, 13

P Padding property of controls, 68Page class

animation example, 875–876FlowDocuments in, 572Frame objects, as Source for, 571NavigationService class, 569NavigationWindows with, 567PageFunction class, 584–586XAML Browser Application use of, 598

pagination for printing, 387–390, 411, 425–434 Panel class

canvases. See Canvas classChildren property of, 89–90, 91, 235. See also custom

panelsclass hierarchy for, 89customizing. See custom panelsDockPanels. See DockPanel classdynamic layout for, 89Grid panels. See Grid classhandlers for children's events, 167inheriting from. See custom panelsInternalChildren property, 235nesting, 94–95purpose of, 89StackPanels. See StackPanel classUniformGrids. See UniformGrid classWrapPanels. See WrapPanel class

992 parsing

parsing BrushConverter class, 507conversions of types, 504–506EnumConverter class, 506Parse method of Double, 504–506Path strings for data binding, 616ThicknessConverter class, 505–506XAML by System.Windows.Markup, 462XamlReader.Load for, 462–463

partial keyword, 323, 416Paste commands, implementing, 74–76, 320Path animation classes

DoubleAnimationUsingPath, 930–934MatrixAnimationUsingPath class, 934–937PathAnimationSource.Angle, 931purpose of, 929

Path class (geometrical shape) animation of. See Path animation classesArcSegments. See arcsClip property, 814–815closed figures, 790Combine method, 53CombinedGeometry. See CombinedGeometry classData property of, 783, 785defined, 781EllipseGeometry class, 785figures, 790FillRule issues, 793font customization, 815–818Geometry type, 783GeometryGroup class, 785–787graphics paths defined, 790LineGeometry class, 784LineSegment class, 792multiple elements, 786–787open figures, 790PathFigure objects, 791–792PathGeometry objects. See PathGeometry classPathSegment objects, 791–792PolyBezierSegment class, 804–805PolyLineSegment class, 793–794purpose of, 783QuadraticBezierSegment class, 811–812RectangleGeometry class, 784–785RotateTransform with, 888StrokeDashArray property, 780, 899subpaths, 790Transform property of, 843

Path property of Binding class, 606–607, 615, 616PathFigure class

class hierarchy for, 791defined, 791derivation, 791FillRule issues, 793IsClosed property, 791, 793IsFilled property, 791, 793LineSegment class, 792

PathSegment objects, 791Segments property, 791, 792StartPoint property, 791, 792

PathGeometry class animation classes with, 929–930Bézier curves defined in, 930–931figures, 790Figures property, 791, 792FillRule property, 791, 794graphics paths, 790subpaths, 790

PathSegment class arbitrary polygon creation, 792ArcSegments. See arcsBézier curves with, 802class hierarchy for, 791defined, 791PathSegmentCollection, 792PolyLineSegment class, 793–794

Pen class DashCap property, 777DashStyle property, 777PenLineCap enumeration, 772–774, 778–779PenLineJoin enumeration, 774–777properties, table of, 771–772

pixels device independent units, 17formats, 945PixelFormats class, 940, 942

png files. See bitmapspoint sizes of fonts, 47PointAnimation class, 887–888PointAnimationUsingKeyFrames, 913–914, 926PointAnimationUsingPath class, 929–930PointCollections, 761–763pointers, mouse, obtaining locations of, 28Points property, 761–763points, specifying collections of, 506PolyBezierSegment class, 804–805Polygon class

arbitrary polygon creation, 792creating objects in a canvas, 133curve creation, 762–765fill rules for, 133, 765, 767–769Grid class with, 761Points property, 761–763StrokeLineJoin property, 774–777Style definitions for, 768–769

Polyline class coordinate system marking with, 846curve creation, 762–765fill rules for, 765, 767–769Grid class with, 761line joins, 774–777Points property, 761–763positioning in Content, 763purpose of, 177–180

RichTextBox controls 993

PolyLineSegment class, 793–794positioning Window objects, 16–20PresentationCore reference, adding, 4preview events, 85–86, 169–176printing

Arrange method requirement, 387banner printing, 388–392, 409–411color presentation. See Color structuresDocumentPage class, 387, 390DocumentPaginator class, 387–390DrawingVisual class, 375–377, 390GetPage method, 387, 390Grid objects, 385–387margin settings, 378Measure method requirement, 387multi-page documents, 387multiple pages, 385multiple printers, 378PageOrientation property of PrintTicket, 427PageRangeSelection property, 377pagination, 387–390PrintableAreaWidth/Height properties, 377PrintDialog class, 375–378PrintDocument method, 387Printer Preferences field, 377PrintQueue fields, 375, 378PrintTicket class, 375, 377–378, 427PrintVisual method, 377, 385–387Visual type, 375, 385, 387, 390

projects code files, adding, 4creating new, 4properties of, setting, 5references, adding, 4

properties. See also properties under specific classesattached. See attached propertiesdependency. See dependency propertiesdetermination by reflection, 504EnumConverter class, 506parsing inconsistent string representations, 504–506XAML representations of, 508–510, 514–515, 521, 606

Q-R QuadraticBezierSegment class, 811–812RadialGradientBrush class, 38–41RadioButton controls, 76, 100–102, 646, 669raster graphics, 939. See also bitmapsrasterization, 815ReachFramework.dll, 377–378Rectangle class

Canvas.Left and Top properties, 760dimensions, setting, 760DrawRectangle methods, 956–957Grid class with, 761rendering paradigm, 760StrokeLineJoin property, 774–777

RectangleGeometry class, 784–785recursing directory trees, 344–345, 351–353references, adding using Solution Explorer, 4reflection, metadata, 31reflections of graphics, 965–966reflections of text, 855–856RenderSize property

ArrangeOverride return values, 210dimension calculation for, 187explicit Width or Height settings, 187HorizontalAlignment property effects, 187–188, 190Margin property effect on, 187, 188–189purpose of, 186ScaleTransform, effects of, 826

RenderTargetBitmap class, 942–943 RenderTransform property

compared to LayoutTransform, 823coordinate systems for Canvas, 844–846defined, 819drop shadow creation, 848–849LayoutTransform compared to, 831–833line widths, effect on, 844Matrix, setting directly, 842MatrixTransform, setting to, 937OnRender method, 831RadialPanel example using, 254RenderTransformOrigin property, 833–835rules for, 831ScaleTransform with, 827setting to TranslateTransform, 821SkewTransform with, 829–830TranslateTransform with, 824Value property, 841

RepeatBehavior animation, 870, 873, 892, 893resources

adding to projects, 71assembly, 71, 523–524defined, 71locally defined. See XAML resourcesResourceDictionary type, 524ResourceKey property, 537–538StaticResource syntax, 641, 644styles, defining in, 640–641template selection, 685–686templates, defining as, 667Uri class to accessing, 72XAML. See XAML resources

retained graphics system, 860RichTextBox controls

command processing, 320Document property, 88FlowDocument class, 330, 500–502FontFamily, setting, 330formats used, 85keystroke visibility issue, 85–86loading files with, 324–328

994 RotateTransform

RichTextBox controls, continued preview events, 85–86purpose of, 80saving files with, 324–328Selection property, 329–330TextRange class, 88, 329–330toolbars, inside, 319–320

RotateTransform affine transforms, 838Angle property of, 830–831, 916animating, 879–880Center properties of, 830, 831, 833coordinate system issues, 846formulas, 837–838line rotation techniques, 835–837MatrixTransform equivalence, 842negative angles, 831Path rotation, 888rotating around center, 833–834rotating TextBlock objects, 854–855syntax for, 821XAML example, 820–821

rotating bitmaps, 941Round line joins, 774–777routed event handling, 176, 180–183, 195–202routed input events

AddHandler method, 166–167, 168advantages of, 165bubbling events, 165, 168capturing, 166, 171–172class hierarchy of RoutedEventArgs, 157–158Click event routing, 166–167ContentElement class events, 169custom event creation, 168–169defined, 157–158Device property of InputEventArgs, 161enabled elements issue, 158Handled flag, 161, 166InputEventArgs, 161keyboard events, 167–168mouse events, 169–176no default implementations of events, 159OriginalSource property, 160–161, 164–166, 169purpose of, 158raising custom events, 168–169RegisterRoutedEvent method, 168RemoveHandler method, 168RoutedEvent property, 160, 164, 864RoutedEvent type, 160, 168RoutedEventArgs class, 160–161, 164, 165, 168–169RoutedUICommand type, 308–311, 317–320RoutingStrategy, 168senders, 165–166sequence of control, 165Source property, 160–161, 164–166

TimeStamp property of InputEventArgs, 161tunneling events, 165, 168UIElement events, 158visibility issues, 158

Run method of Application class, 4, 6, 12

S saving files for data entry, 726, 729ScaleTransform

ActualWidth property, effect on, 826Center properties, 824, 826, 827Matrix equivalence, 840–841properties of, 824RenderSize property, effect on, 826RenderTransform vs. LayoutTransform, 827Scale properties, 824–827scaling formula, 826–827syntax for, 821XAML example, 820–821

scaling graphic images, 766–767 scRGB color space, 24–25 ScrollBar controls

data binding example, 614–615derivation of, 127double values used for properties, 127events of, 97–98Orientation property, 127Scroll events, 127SmallChange property, 127Template property of, 663

ScrollViewer class Margin property, 97purpose of, 95ScrollBar events, 97–98SizeToContent with, 97StackPanels and contents of, 95–96visibility properties, 97WrapPanel with, 103

security permissions, 598senders, 164–166Separator controls of menus, 290serialization, 414–417shadows, creating, 965–966Shape class. See also graphical shapes

Brush type properties, 760Canvas class with, 760class hierarchy of, 56–57, 759composites, constructing, 760curve creation, 762–765Ellipse class of. See ellipsesEvenOdd FillRule, 767–771Fill property, 760fill rules for, 765, 767–769Grid objects for holding composites, 761line caps, 772–774

StackPanel class 995

Line class of. See Line classline joins, 774–777NonZero FillRule, 767–771paths. See Path classPolygons. See Polygon classPolylines. See Polyline classpositioning in Canvas objects, 760–761Rectangles. See Rectangle classrendering paradigms, 760Shapes library, 759strokes with. See Stroke classStyle elements with, 766XAML for property definitions, 772

shapes, graphic. See graphical shapesShowDialog method, 13, 83, 377, 379sine wave simulation, 762–763single-child elements

AddLogicalChild method, 206, 212Arrange method, 203–204, 207ArrangeOverride method, 203–204, 207, 209–210Child property, 206––208Decorator objects, 210DesiredSize property, 207, 209DrawingVisual class, 224element trees of, 208five common overrides, 203–204GetVisualChild method, 203, 206, 224–226layout process description, 208logical trees, 206Measure method of children, 207–209MeasureOverride method, 203, 206–209OnRender method, 204sequence of calls for overriden methods, 204sizing of, 208–209templates. See templatesvisual trees, 206, 208VisualChildrenCount, 203, 206, 224–226

single-threaded apartments, 4SizeToContent property

custom element sizing issues, 189custom panels effects, 239purpose of, 48ScrollViewer class use of, 97sizing windows to image sizes, 55

sizing of custom elements alignment property effects, 187aspect ratio maintenance, 190calculation by MeasureOverride, 199–200child element effects on, 206–209childless elements, 190clipping, 188, 194, 201–202desired size, 188–189DesiredSize property, 209FormattedText type issues, 193–199HorizontalAlignment property effects, 187, 190

Margin property effects on, 187, 189MaxWidth and MaxHeight, 187, 190MeasureOverride method. See MeasureOverride

method minimum preferred size, 188–189 MinWidth and MinHeight, 190natural size, indicating, 190public property caveat, 188RenderSize property. See RenderSize property Width and Height, 187, 188, 190, 191

sizing Window objects, 16–20SkewTransform

Angle properties, 827–828Center properties, 829creating, 821formulas for, 828–829horizontal skew, 828large angles, 829LayoutTransform vs. RenderTransform, 829–830properties of, 827rotation with, 829vertical skew, 828XAML example, 820–821

smoothing animations, 892–893 SolidBrushColor brushes, 26–32 sorting, 363–364, 745–746 sources, data binding

DataContext property, 610–611defined, 605Mode property, 607–610notification mechanisms, 612RelativeSource property, 636–638requirements, 607Source property of Binding class, 607–608, 627, 630

splines Bézier curves as, 798. See also Bézier curvesKeySpline property, 919–926SplineDoubleKeyFrame class, 910, 920SplinePointKeyFrame, 926, 930Spline<Type>KeyFrame classes, 910, 919–926

splitters, 122–127sRGB color space, 24StackPanel class

alignment of buttons, 92Background brushes for, 91button Name property, 93Children collection of, 91, 93class hierarchy, 89ContentProperty attribute, 515–516 custom element sizing issues, 189default arrangement of children, 91event monitoring, 93–94 FindName property with, 93index for children, 93inside buttons, allowing multiple objects, 98

996 stand-alone XAML

StackPanel class, continued margins for, 92–93nesting panels, 94–95Orientation Property, 91purpose of, 90styles with, 641template role for other classes, 690–691ToolBar button and text display with, 320transform issues, 831VirtualizingStackPanel, 690–691XAML snippet example, 457–458

stand-alone XAML, 460Startup event of Application class, 8StatusBar class, 339, 690–691, 693–696storyboards

attached properties of, 865BeginStoryboard class, 864, 866class hierarchy for, 864–865consolidation of multiple timelines, 865ControllableStoryboardAction. See

ControllableStoryboardAction classdefined, 864durations, effects on subordinate objects, 892EnterActions collections, 879ExitActions collections, 879Forever setting, 892HandoffBehavior property, 877–878multiple animation support, 871–872ParallelTimeline elements, 873–875PauseStoryboard action, 883RepeatBehavior attribute, 873SeekStoryboard action, 883SpeedRatio property, 873TargetName attached properties, 866–867, 868TargetProperty references, 866, 871TimelineGroup ancestor of, 871triggers, acting as, 866

Stretch properties, 54–55, 190, 962–963 strings

immutability of, 50StringAnimationUsingKeyFrames, 918StringBuilder objects, 50–51

Stroke class colors, 550DashCap property, 780DrawingAttributes property, 550, 552–553, 555–557,

562DrawingGroup objects, 552–553DrawingImage class, 553GetGeometry method, 552–553InkCanvas property for, 177PressureFactor property, 550property for, 192–193Save method, 550saving as XAML Drawing Files, 552–553

Stroke collections of InkCanvas, 549–550StrokeDash properties, 777–779, 780StrokeLineJoin property, 774–777StrokeMiterLimit property, 777StrokeThickness property, 772, 893stylus effects, 550StylusPoints property, 550table of, 771–772

styles animation of, 876–880BasedOn attribute, 646–649class definition, 639ControlTemplate objects, controlling, 669data binding Values, 650, 652–653DataTrigger class, 659–660defined, 639dependency property issues, 650EventSetter objects, 639, 654–655FlowDocument objects, 653–654FontSize property, setting, 640, 645Foreground property, setting, 640, 645gradient brushes in, 643–644graphics using, 651–653heterogenous elements, applying to, 641–642hierarchy of styles, defining, 649Image objects not supported, 650IsSealed property, 656keys, 646–647Line class with, 652–653local settings, precedence of, 640multiple resource sections, same key with, 642–643null Values, 640precedence of settings, 640, 647–648Property attribute, 639purpose of, 639RadioButton margin settings, 646referencing, 640RelativeSource property, 652–653Resources, 640–644restrictions on, 650Setters property, 639, 645StaticResouce markup extension, 641, 644Style class definition, 639Style property of FrameworkElement, 640TargetType property, 644–646templates compared to, 663Triggers property, 656–660unique properties of elements with, 642Value attribute, 639, 643, 650XAML resources for, 527XAML Setter syntax, 639x:Key attribute, 645, 648x:Type extension, 644–646

stylus information, 167, 177–180, 550–555subpaths, 790

TileBrush class 997

T Table class, Grid objects compared to, 111Tablet PCs

eraser mode, 553–555InkCanvas interface, 177, 180, 545–546PressureFactor property, 550strokes, 177, 549–550stylus events, 167, 177, 550StylusPlugin namespace, 177

TargetName attached properties, 866–868, 879TargetProperty for animations, 866targets, data binding, 605, 607–610, 629–630taskbars, 12, 378templates

ApplyTemplate method, 697binding to Content properties, 670, 680binding to data, 710CellTemplate objects, 663–664class hierarchy of, 664content, changing only, 677–679ContentPresenter class with, 669–670ContentTemplateSelector property, 685–688Control class Template property, 219–223, 663–664,

672–677ControlTemplates. See ControlTemplate classDataTemplates. See DataTemplate objectsDataTrigger tags, 707defaults for, examining, 672–677FindResource method with, 685FrameworkTemplate base class, 664Help system using, 710–717HierarchicalDataTemplate type, 354–355, 663–664IsSealed property, 664ItemsControl class with, 690–691ItemsPanelTemplates. See ItemsPanelTemplate objectsItemTemplate property, 279–281, 663–664, 692–693,

707ItemTemplates. See ItemTemplate propertyName attributes, 697resource selection, 685–686resources, defining as, 667Resources property, 664SelectTemplate method, 685–688styles compared to, 663TemplateBinding markup extension, 666–667TextBlock class, binding to controls, 666–667TreeView controls using, 709–710VisualTree property, 664–665XAML for template definitions, 665

termination of programs, 5, 12text

Bold objects, 60button content, 70Canvas objects, placement in, 135color, setting, 48

Content property, setting to, 45–46coordinate system issues, 846custom fonts for, 815–818DrawText method, 193–195drop shadows, 848–849em sizes, 46–47file I/O, 85FontFamily, setting, 46–47FontSize, setting, 46, 47FontStyle property, 47FontWeight property, 47FormattedText type, 193–199, 202italics, 47, 60oblique, 47point sizes, 47properties for, setting, 46–49reflecting, 855–856rich text. See RichTextBox controlrotating, 854–857StringBuilder objects, 50–51styles, setting for, 653–654TextBlock objects. See TextBlock classTextDecorationLocation enumeration, 315ToString methods for generating, 48–49wrapping, property for, 425–434, 446–448

TextBlock class AcceptsReturn property, 83binding with templates, 666–667Bold objects, 60content property, 516dialog box access to Text, 82FontSize property, 60Foreground property of, 60–61implicit creation of objects, 59Inlines property of, 59, 60, 516Italic objects, 60Opacity, animating, 917parent class, 59purpose of, 58rotating TextBlock objects, 854–855styles, targetting with, 645templates, binding to controls, 666–667user-input events, 61–62

TextBox controls binding to, 447–449, 625class hierarchy for, 80expansion to fit text, 83filters with, 751–754rich. See RichTextBox controlsText property of, 80TextWrapping property, 425–434

TextElement classes, 653Thickness structure, 55threading, 4TileBrush class, 958, 962–965

998 Timeline type

Timeline type, 863–865, 871, 873–875. See also storyboards

timers animation based on, 859–860AnimationClock type, 863comparision of Timer classes, 41CreateClock method, 863disadvantages for animation, 899DispatcherTimer class, 41TimerOnTick method, 860

TimeSpan objects, 862titles, setting for Window objects, 21ToggleButton class, 76–79ToolBar class

ApplicationCommands for, 317BandIndex property, 323, 324buttons for, 319, 320, 327class hierarchy for, 321components for, 317creating toolbars, 317–319DockPanels with, 324Edit menu command examples, 328–329event handlers, 319focus, setting, 319formatting text, 329–331grip images, 320Header property, 317, 320, 322–323Items collection, 317keyboard interfaces, 319menus as members in, 337Orientation property, 322–323placement of toolbars, 317populating toolbars, 317–319positioning toolbars in trays, 322–323RichTextBox controls in, 319–320, 324RoutedUICommand objects for, 317–320StackPanels for text with buttons, 320text with buttons, 320ToolBarOverflowPanel, 321ToolBarPanel, 321ToolBarTray class, 321–323, 324tooltips, 317, 319width issues, 321

ToolTip class ListBox controls, using in, 283multiple objects in content. See Panel classsetting up for buttons, 79–80toolbar buttons with, 317, 319

ToString methods, 48–49 transforms

affine transforms, 838animating, 879–880, 886class hierarchy for, 819–820coordinate systems for Canvas, 844–846defined, 819

DesiredSize property, effects on, 831drawing area vs. elements, 822–823drop shadows, 848–849Geometry class, Transform property of, 843horizontal skew, 828LayoutTransform property, 819, 823, 824, 829–833line widths, effect on, 844matrices for. See matricesMatrixTransform class, 842Path objects with, 843purpose of, 819RadialPanel example of, 254RenderTransform property, 819, 821, 823, 824,

829–830 RenderTransform vs. LayoutTransform, 831–833 RenderTransformOrigin property, 833–835 rotations, 820–823, 829, 830–831, 833–834 ScaleTransform, 820–821, 824–827, 840–841,

850–851SkewTransform, 820–821, 827–830, 850–851StackPanel issues, 831TransformGroup class, 843, 857, 902TranslateTransform, 820–821, 823–824, 840, 902types of objects transformable, 819UIElement basis for, 819UniformGrid issues, 831–832Value property of Transform class, 840, 852vertical skew, 828XAML multiplications with, 851–852

TranslateTransform property animations, 902C# example, 821drop shadows, 848–849LayoutTransform vs. RenderTransform with, 824Matrix equivalence, 840origin calculation, 824properties of, 823XAML example, 820–821

transparency, 23, 55–56. See also opacity TreeView controls

bitmap graphics in, 346class hierarchy, 341Collapse event, 345–346dependency properties of, 366directories, displaying, 343–354DispatcherObject descendents, displaying, 356–357events of, 345–346Grids with, 353Header property, 341–342, 347HierarchicalDataTemplate class, 353, 355IsSelected property, 345–346ItemCollection objects, 343Items property, 341, 343ItemsSource property, 356, 709–710ItemTemplate property, 353, 356, 663–664

visited links journals 999

lazy loading, 345–346navigating, 343OnExpanded method, 349OnSelected method, 347populating, 342–354purpose of, 341recursion of, 344–345, 351–353refreshing, 350–351SelectedItemChanged event, 345–346, 353strategy for discovery time minimalization, 345templates with, 709–710TreeViewItem class, 341, 343, 356TypeTreeView class, 356–357Unselected event, 345–346Windows Explorer pane as example, 341

triggers for animation Actions property, 864BeginStoryboard class, 864, 866cross-element triggering, 875–876elements with events, 864EventTrigger class, 864, 868, 878, 883Loaded event triggers, 883Name attributes of elements with events, 864purpose of, 864RoutedEvent property, 864SourceName property of EventTrigger, 864, 868TargetName attributes, 868Trigger class, 878–879TriggerAction objects, 864, 880, 881TriggerBase objects, 864Triggers section samples, 864, 865–866, 883

Triggers property of Style class hierarchy, 656–657DataTrigger class, 659–660defined, 656EventTrigger class, 656–657mechanics of, 657precedence rules, 658Setters property, 657syntax of, 657TriggerBase class, 656type of, 656

tunneling events, 165, 168Type class, 31, 366–367typefaces. See also fonts

button content, 70defined, 46em sizes, 46–47FontFamily, setting, 46–47FontSize, setting, 46, 47point sizes, 47Typeface objects, 193–194

U UIElement class

Arrange method, 203–204child elements based on, 243–244class hierarchy for, 223CommandBindings property, 74Content property use of, 51–52dependency properties, 144events defined by, 6Image class, 52input, routing. See routed input eventsOnRender method, 51Panel class hierarchy, 89printing instances of, 387purpose of, 51RenderSize property, 186–187RenderTransform property of, 819RenderTransformOrigin property, 833–834shapes. See Shape classtransformability of, 819UIElementCollection class, 93, 235, 242–244

underline character in menus, 291UniformGrid class

child elements of, 130class hierarchy, 89custom panels mimicking, 235–237ListBox controls, displaying in, 691ListBox controls using, 281–283purpose of, 90, 130transform issues, 831–832

URIs (Uniform Resource Identifiers) accessing resources with, 72Uri constructor, 53Uri objects, 940

user application data, 414

Vvector graphics

defined, 939DrawingGroups. See DrawingGroup classGeometryDrawing class, 950–951

Vector type, 28, 36–37vertical skew, 828VerticalAlignment property, 55, 68–69, 187–188video, 952, 957Viewbox class, 98, 766–767, 846–847, 969–976viewing data. See CollectionView; data entryViewport property, 963–965virtual methods, overriding, 160visability events, 158visited links journals. See journals

1000 Visual class

Visual class class hierarchy for, 223–224 GetVisualChild method, 203printing. See printing, Visual type styles not supported, 650visual tree components, 223VisualChildrenCount property, 203

visual objects, 143visual trees

AddVisualChild method, 206, 212, 224building for TreeView controls, 356components of, 223DataTemplates, of, 680defined, 143dependency property propagation, 144GetVisualChild method, 224–226ListBox controls, for, 281VisualChildrenCount, 224–226VisualTree property of ControlTemplate, 219VisualTreeHelper class, 208Window objects, typical, 208

Visual type, 375, 387VisualBrush class, 959, 962, 963–965VisualChildrenCount property, 203, 206, 235visuals. See DrawingVisual class; visual trees

W Web browser color support, 25–26 Window class

ActualHeight property, 16–20ActualWidth property, 16–20Background property, 22client areas, 23content. See Content propertyContentControl as parent class, 45creating objects, 3element tree of, 208event handlers obtaining, 8Foreground property brush, 55formats for, setting, 21–22Height property, 16–20inheritance from, 13–17initialization, 15Left property, 18–20MainWindows property of Application, 10–11, 12minimum size of, 18MouseDown events, 15multiple instances of, 10–13multiple objects in content. See Panel classOwner property, 13parent class of, 45parts of, 6positioning on screens, 16–20purpose of, 4ResizeMode property, 22

Show method, 4ShowDialog method, 13sizing, 16–20styles for, setting, 21–22taskbar, multiple windows in, 12Title property, 4, 21Top property, 18–20Topmost property, 22Width property, 16–20WindowCollection class, 11–12WindowColor property, 31WindowStartupLocation property, 19WindowState property, 22WindowStyle property, 21XAML representation of, 548–549

Windows property of Application class, 11–12WindowsBase reference, 4WinFX Windows Application project type, 529wizards

defined, 575fixed sized windows, 577journals for, 580navigation buttons for, 575Next buttons for, 582PageFunction class, 584–586Previous buttons for, 582state requirement, 575

work area of screens, 18–19 WrapPanel class

class hierarchy, 89ItemHeight property, 102–103Orientation property, 102–103purpose of, 90, 102–103ScrollViewer with, 103template role for Menu, 690–691

wrapping text, 425–434, 446–448

X-Y XAML Browser Applications, 597–603 XAML Cruncher program, 487–519 XAML data binding

conversions of types for, 617–620DataContext, setting, 610–611delayed updating, 625–627dependency properties, 612, 615DependencyObject derived targets, 629–630events defined for, 631–632multi-bindings, 620–625, 635–636Path property, 615–616RelativeSource property, 636–638Source property, 627–628, 630between two controls, 605–606UpdateSourceTrigger property, 626–627x:Name attribute, 615

XAML resources 1001

XAML (Extensible Application Markup Language) advantages of, 458Application object, files for, 479–480, 482–483attached properties, 517–518, 521attributes, 514–515, 519, 521–522BAML files, 474–475browser applications, 597–603Build Action for, 471–472, 481Button tags, 514–515C# code equivalence example, 457casting as buttons, 463–464CDATA sections, 484Class attribute, 470–471, 472, 477–478class names with attributes, 519class selection by XamlReader.Load, 503–504code behind files with, 469–471, 473–474, 476–477Code element, 470, 484CommandBinding elements, 546–548compiling with source code, 469–470, 475concise expressions in, 457constructors, replacing with, 458Content property, 514–516content, setting to, 463, 466, 475Cruncher program. See XAML Cruncher program{} (curly brackets), 526custom classes in, 475–478data binding. See XAML data bindingdefined, 457Drawing Files, saving strokes as, 552–553element names, interpreting, 521–522element tree representation, 461EmbeddedCode project, 483embedding C# in, 483–484embedding in C# programs, 462empty element syntax, 458enumeration assignments, 458error messages for, 460event handlers, 458, 464, 466, 469–470, 473, 474events, 519–520, 522files, loading, 468–469gradient brushes, defining, 512–513graphical shapes creation example, 765–766Image elements, 486InitializeComponent method, 474, 475, 480launching files of as programs, 459–460locating elements by name, 466loose XAML, 460markup extensions in. See markup extensionsmultiplications using transforms, 851–852Name attributes, 473names of elements, interpreting, 521–522namespaces, 459, 470, 475–476, 510–512non-WPF, 470object elements, 507objects, reusing. See XAML resources

Page class creation, 460parsing, 462, 503–504partial class definitions, 471, 472–473property attributes, 508property elements, 508–510, 514–515purpose of, 457, 458resources in executables, as, 464–466resources, local. See XAML resourcesroot elements, 461specification, 470stand-alone files, 460StartupUri attribute, 481, 483Stream objects with Load, 462–463, 466string variable assignment, 462styles created in. See stylessyntax, importance of learning, 458template creation with, 665–666. See also templatestransforms with. See transformsvisual appearance role of, 458Visual Studio designer for, 458Web site launches of, 460Window class representation, 548–549Window classes with XAML and code-behind, 471Window-derived classes entirely in, 478–479window hierarchies in, 457–458Window objects loaded into Application objects, 467Window objects Owner property, 469Window root elements prohibited, 461, 467x prefix, 470XAML-only projects, 481–482XamlReader.Load method, 460, 462–464, 469, 475,

487, 503–504XamlWriter.Save method, 462x:Static, 532–537x:Type extension, 644–646x:XData elements, 705XML data islands, 705, 708XmlNamespace property, 504xmlns attribute, 459XmlnsDefinitionAttribute, 504XmlTextReader, 469

XAML resourcesAdd method, 528application-wide resources, 529–530Application.Resource tags, 532availability of, 524C# for adding, 528classes defining Resources property, 524converter classes in, 618, 620{} (curly brackets), 526defined, 523–524defining elements as resources, 528DynamicResource, 538–541FindResource method, 528–529format of, 524

1002 xbap files

XAML resources, continued forward referencing, 539instance properties, 535–536Internet Explorer permissions, 533key lookups, 526–527Key properties, 537local nature of, 524markup extensions, 524namespace associations, 534–535placement of Resources section, 526purpose of, 523–524, 527ResourceDictionary root elements, 542–544ResourceKey attributes, 525–526, 537–538Resources property, 524scope of, 524setting properties, 524sharing among applications, 542–543sharing of, 528StaticResource, 524, 525–526, 537storage object type, 524styles with. See stylessyntax, 526system-associated keys, 541updates, 536–537Visual Studio creation of, 529–530x:Static, 532–537

xbap files, 545, 597x:Class attribute, 680, 693–694x:Key attribute, 645, 648, 667x:Name attribute, 615

x:Static markup extension C# defined properties, 533–534DynamicResource, 538–541file structure options, 535Internet Explorer permissions, 533Key properties, 537namespace associations, 532–533non-WPF class access, 532purpose of, 532ResourceKey property, 537–538Source property of Binding class, 627syntax, 532type consistency required, 532updates, 536–537

x:Type markup extension, 644–646x:XData elements, 705XML (Extensible Markup Language)

application version of. See XAML (Extensible Application Markup Language)

attribute assignments, 457data islands, 705, 708Deserialize method, 414element components, 457empty element syntax, 458local user application data, 414serialization, 414–416, 726, 729@ symbol for attribute references, 707user application data, 414x:XData elements, 705XmlNamespace property, 504XmlnsDefinitionAttribute, 504

XPath property, 705–707, 709–710 YellowPad project, 550–574