Windows Forms FAQ

WPF FAQ

Welcome to the WPF FAQ. Questions and answers in this FAQ have been collected from newsgroup posts, various mailing lists and the employees of Syncfusion. If you have a FAQ, or any other good WPF resource, please e-mail us.

Search Help
 

General

  • General
  • Concepts

  • Element Tree
  • Dependency Property
  • Resources
  • Coding Techniques
  • Threading
  • Freezable Object
  • Input and Commands.
  • Layouts
  • XAML

  • Styles and Templates
  • XML Namespaces
  • Binding Techiniques
  • Type Converters
  • Content Model

  • Templates
  • Decorator Content Model
  • Documents

  • Serialization and Storage
  • Annotations
  • Flow Content
  • Printing
  • Graphics and Animation

  • Rendering Graphics
  • 2D Graphics
  • 3D Graphics
  • Visual Layer
  • Animation
  • Control Customization

  • Adorners
  • Stylable controls
  • ControlTemplates
  • Data

  • DataBinding
  • Data

  • Serialization
  • Globalization and Localization

  • Attributes
  • Comments
  • Globalization Struc
  • Application and Deployment

  • ClickOnce
  • Frame
  • Page
  • Navigation
  • Setup
  • Window
  • Interoperability

  • Message Loops Between
  • Win32 in WPF
  • WPF in Win32
  • Windows Forms and WPF
  • Security

  • Trusted Security
  • Partial Trust Security
  • Tools

  • Microsoft Expression Blend
  • ZAM3D
  • XAMLPAD
  • Controls

  • Drag and Drop
  • Menu
  • Custom Controls
  • RichTextBox
  • TextBox
  • TextBlock
  • TabControl
  • DocumentViewer
  • Image
  • StatusBar
  • Buttons
  • ProgressBar
  • Slider
  • Canvas
  • Border
  • Expander
  • GridSplitter
  • Context Menu
  • Popup
  • ToolTip
  • ItemsControl
  • TreeView
  • ComboBox
  • ListView
  • ListBox
  • 1. General

      

       1.1What is WPF?
       1.2What is XAML?
       1.3What is XBAP?

    2. Concepts Element Tree

      

       2.1How can I enumerate all the descendants of a visual object ?

    3. Concepts Dependency Property

      

       3.1How can I create Custom Read-Only Dependency Properties ?
       3.2How can I mark the default value of a custom dependency property to be false?
       3.3What are Attached Properties and how to register it?
       3.4How can I set an attached property in code?

    4. Concepts Resources

      

       4.1How can I use an application resource ?
       4.2How do I view the XAML resources compiled into an assembly in BAML format?

    5. Concepts Coding Techniques

      

       5.1What is the use of x:code ?
       5.2How do I create in-line event handlers?

    6. Concepts Threading

      

       6.1What is the equivalent of the Windows Forms OnIdle event in WPF?

    7. Concepts Freezable Object

      

       7.1How can I determine whether a Freezable Is Frozen?
       7.2How can I obtain a writable copy of a Read-Only Freezable?

    8. Concepts Input and Commands.

      

       8.1What built-in commands are defined in the WPF framework?
       8.2How can I add a CommandBinding to a window using markup?
       8.3How do I capture Ctrl + Enter key press in my TextBox?
       8.4How do I change the background of my Grid layout when one of it's children gets keyboard focus?

    9. Concepts Layouts

      

       9.1When I try to add multiple controls to a button it shows an error, how do I add multiple controls to a button?

    10. XAML Styles and Templates

      

       10.1How can I create a Style deriving from another Style?
       10.2How can I set a ControlTemplate in the style template?
       10.3How can I create a custom WPF button whose look and feel depends on the Windows desktop theme currently in use. How do I get notified when the user changes the theme?
       10.4What are the limitations of Inline Styles and Templates ?
       10.5How do I see the templates used by the WPF framework controls?
       10.6How do I access extended properties from a XAML tempalte?

    11. XAML XML Namespaces

      

       11.1How can I map CLR Namespaces to XML Namespaces in an Assembly ?
       11.2Which namespace is used to associate namespace identifiers with element names ? Is there any effect on the attributes ?

    12. XAML Binding Techiniques

      

       12.1How do you bind the available system fonts to a combobox and bind to the selection?

    13. XAML Type Converters

      

       13.1How can I apply the TypeConverter Attribute?

    14. Content Model Templates

      

       14.1How can I create Four Button controls with the contents set to a String, a DateTimeObject, an UIElement and A Panel that contains other UIElement objects?
       14.2Can I create a ContentTemplate and apply the template to a ContentControl ?
       14.3How can I define a style for a ContentControl to give it a meaningful appearance in the UI ?
       14.4How can I create a ControlTemplate for a HeaderedItemsControl ?
       14.5How can I get an enumerator to the ContentControl's logical child elements ?
       14.6How do I programatically interact with template generated elements?
       14.7How do I create a template programatically?

    15. Content Model Decorator Content Model

      

       15.1How do I create a Borderless Window in WPF ?
       15.2How can I animate a BorderThickness value ?

    16. Documents Serialization and Storage

      

       16.1How can I store a given document in a specific format using CreateSerializerWriter methods ?
       16.2How can I use MemoryStream to create a deep clone of a serializable object ?
       16.3How can I do versioning using Custom Serialization ?

    17. Documents Annotations

      

       17.1How can I Match Annotations with Annotated Objects ?
       17.2How can I create an application that is used to declare a Context Menu with routed commands that the users can access to create and manage annotations ?

    18. Documents Flow Content

      

       18.1How can I load an XAML file into a FlowDocumentReader?
       18.2How can I save the contents of a FlowDocumentReader as an XAML file ?
       18.3How can I store a given document in a specific format using CreateSerializerWriter methods ?
       18.4How do I load a FlowDocument XAML content from outside the application directory?
       18.5How can I define three paragraphs under one section ?
       18.6How can I use the BlockUIContainer element to host UIElement objects within Flow content ?
       18.7Can I embed a figure into a paragraph of text ?

    19. Documents Printing

      

       19.1How can I programmatically print XPS Files ?

    20. Graphics and Animation Rendering Graphics

      

       20.1How rendering in WPF differs from WIN32 applications?
       20.2How can I use a DoubleAnimation to rotate the textblock ?
       20.3How can I create a combined hard and soft shadow ?
       20.4How do I execute 2 animations in parallel?

    21. Graphics and Animation 2D Graphics

      

       21.1How do I apply BitmapEffect to a particular area of an Image ?

    22. Graphics and Animation 3D Graphics

      

       22.1What are the properties that reduce the performance of 3D graphics rendering?
       22.2How lights are useful in 3D graphics ?

    23. Graphics and Animation Visual Layer

      

       23.1How HitTest methods in VisualTreeHelper is useful ?

    24. Graphics and Animation Animation

      

       24.1At the end of animation, how do I cause the value of a property to revert back to it's original value?
       24.2Performance gets reduced even after navigating away from a page that contains animation. How do we handle this issue ?
       24.3How do I apply an animation without using a storyboard ?
       24.4What are the requirements for a property to be animated?
       24.5How do I trigger an animation when the data in the control is changed?
       24.6How do I control a Storyboard animation once it starts?
       24.7I have a sequence of animations I want to execute one after another, how do I do that?

    25. Control Customization Adorners

      

       25.1What is an adorner ?
       25.2Where can adorners be used ?
       25.3How to add a custom adorner ?
       25.4How do I bind an Adorner to an Element ?
       25.5How do I remove the Adorner from an element ?

    26. Control Customization Stylable controls

      

       26.1Where can I find information about guidelines to be followed while designing Stylable controls?
       26.2What are the different models for Control authoring ?

    27. Control Customization ControlTemplates

      

       27.1What is the use of a ControlTemplate ?
       27.2How to access elements that are embedded inside the ControlTemplate ?
       27.3How do I build an ItemsControl ControlTemplate ?
       27.4How to edit templates using Microsoft Expression Blend ?
       27.5How to get the default template of a control programmatically ?

    28. Data DataBinding

      

       28.1What is DataContext ? How is it used ?
       28.2What is the use of the RelativeSource property ?
       28.3What are the uses of BindingModes?
       28.4How do I debug my data-binding setup?
       28.5How does TwoWay BindingMode work in an XMLDataProvider?
       28.6Can ItemsControl's Items and ItemsSource properties be modified simultaneously ?
       28.7How do I apply custom sorting to the order of the items in a bound listbox?
       28.8How do I update the source as I type in a TextBox?
       28.9When an XMLDataProvider can be used ? What are it's specific uses ?
       28.10In what way is an ObjectDataProvider useful?
       28.11How to pass a parameter to a constructor using ObjectDataProvider ?
       28.12How to pass a parameter to a function using ObjectDataProvider ?
       28.13How can I bind a method and pass a parameter to the method ?
       28.14How to Get or Set a value that indicates whether to include the DataErrorValidationRule ?
       28.15How do I specify a HierarchicalDataTemplate for a templated type?
       28.16How do I bind to a dictionary including the ability to get notifications when items are added or removed?

    29. Data Serialization

      

       29.1What is Serialization ?
       29.2How to write some XML into IsolatedStorage?
       29.3How do I serialize objects to a binary file ?

    30. Globalization and Localization Attributes

      

       30.1What are the three types of Localizability Attributes and how to use them ?
       30.2What are the best practices for implementing a localizable application?
       30.3How can I set the Language property to the current user's UI language ?
       30.4How can I set the substitution property by overriding the default substitution ?

    31. Globalization and Localization Comments

      

       31.1How can I add localization comments to an XAML file ?
       31.2How can I specify in the .proj file whether to leave the free-form localization comments in the assembly or strip them out ?

    32. Globalization and Localization Globalization Struc

      

       32.1How can I automatically layout Grids Using the IsSharedSizeScope Property ?

    33. Application and Deployment ClickOnce

      

       33.1How does ClickOnce deployment work ?
       33.2Can I add prerequisites in my ClickOnce deployment ?
       33.3How do I enable automatic updates for my application using ClickOnce deployment ?

    34. Application and Deployment Frame

      

       34.1What is the difference between Frame and NavigationWindow ?
       34.2How does Rendering work in Frame control ?
       34.3Can I add dynamic HTML content to a Frame control ?

    35. Application and Deployment Page

      

       35.1Are XAML Browser Applications OS independent ?
       35.2When I run an XBAP application, I get Application Deployment Error. What do I do to overcome this error ?
       35.3How to navigate between pages in an application ?

    36. Application and Deployment Navigation

      

       36.1How to set content of a NavigationWindow ?
       36.2How do I handle Back and Forward button click ?
       36.3How do I pass data between pages in a NavigationWindow ?

    37. Application and Deployment Setup

      

       37.1How do I add registry entries in a setup project ?
       37.2How do I deploy shared components ?
       37.3How launch conditions are useful and how to add one to a setup project ?

    38. Application and Deployment Window

      

       38.1How do I create a child window in WPF ?
       38.2How do I host Windows Forms control in a WPF Window ?
       38.3Does WPF support MDI ?
       38.4How do I show a MessaegBox after my main Window and it's contents are all loaded and visible?
       38.5How do I load a Window from a XAML file dynamically?

    39. Interoperability Message Loops Between

      

       39.1How can I HwndSource Treats ComponentDispatcher Events ?

    40. Interoperability Win32 in WPF

      

       40.1How do I host a Windows Forms control in a WPF application ?

    41. Interoperability WPF in Win32

      

       41.1How do I host a WPF control in a Windows Forms application?
       41.2How can I Host the WPF UserControl in Windows Forms ?
       41.3What is the procedure to host the WPF content in Win32 window ?
       41.4How can I leverage my current investment in Windows Forms applications and still tap into the cool features of WPF ?

    42. Interoperability Windows Forms and WPF

      

       42.1What about hosting user controls and third-party controls including ActiveX controls in a WPF Form?
       42.2Where do I find System.Windows.Forms.Integration ?
       42.3How can I use a WindowsFormsHost element to host a System.Windows.Forms ?

    43. Security Trusted Security

      

       43.1How do I assign full trust to an XBAP application ?
       43.2I am able to access the registry using full trust XBAP application in debug mode, when hosted in an intranet, the application crashes. What do I do?
       43.3How do I get a custom defined permission set of an XBAP application ?

    44. Security Partial Trust Security

      

       44.1How to get data from database in XBAP application ?
       44.2Does permission set of partial trust change in the Local Intranet and Internet?
       44.3How do I detect permission for a file in a partial trust application ?

    45. Tools Microsoft Expression Blend

      

       45.1Can a WPF application be designed using Microsoft Expression Blend ?
       45.2How do I add animations using Microsoft Expression Blend ?
       45.3How do I add custom controls to an application using Microsoft Expression Blend ?

    46. Tools ZAM3D

      

       46.1What is ZAM3D ?
       46.2What are the file formats supported by ZAM3D ?
       46.3Can an XAML file created using ZAM3D be used with Visual Studio.NET ?

    47. Tools XAMLPAD

      

       47.1What is XAMLPAD ?
       47.2Does XAMLPAD support custom controls ?
       47.3Can we see the output of an XAML using XAMLPAD ?

    48. Controls Drag and Drop

      

       48.1What are the objects involved in DragandDrop?
       48.2How do I create a DataObject?
       48.3How do I retrieve data from a DataObject ?

    49. Controls Menu

      

       49.1How can I style a Separator used as a Menu Item ?

    50. Controls Custom Controls

      

       50.1How do I make the UserControl B FILL the UserControl A it's hosted in?
       50.2Is there a good PropertyGrid implementation I could use in my applications?

    51. Controls RichTextBox

      

       51.1How can I Save, Load, and Print RichTextBox Content ?
       51.2How to get the RichTextBox's unformatted text?

    52. Controls TextBox

      

       52.1How do I make a TextBox use all upper-case (or lower-case) characters ?
       52.2How do I support browsing for a text file and reading it into a TextBox?
       52.3How do I hide the default context menu of the TextBox?

    53. Controls TextBlock

      

       53.1How can I make a TextBlock editable when it is clicked and the value is committed when ESC or ENTER is pressed?
       53.2How do I embed a Button into a TextBox?
       53.3How do I bind a TextBlock to a resource string defined in the application's resource1.resx file?

    54. Controls TabControl

      

       54.1How do I validate the current tab before selection changes to another tab on user click?
       54.2How do I dynamically hide and unhide tabs in a TabControl ?
       54.3How do I make the tabs in a TabControl appear on the bottom instead of on top?
       54.4How can I add a style to a TabItem that is used in the TabControl ?
       54.5How do I get a X in my tabs to allow the user to close certain tabs, as in IE?

    55. Controls DocumentViewer

      

       55.1How can I extend the style of a DocumentViewer ?
       55.2How can I reflect via data binding the current Zoom value of a DocumentViewer in a TextBlock?
       55.3How to load an XPS document into the DocumentViewer?

    56. Controls Image

      

       56.1How can I convert an Image to grayscale ?
       56.2How to rotate an image ?
       56.3How do I access / edit the metadata associated with an Image ?
       56.4How can I stamp some text on an image?

    57. Controls StatusBar

      

       57.1How do I create custom layout for StatusBar items?

    58. Controls Buttons

      

       58.1How do I change the shape of the button to an ellipse?

    59. Controls ProgressBar

      

       59.1How can I create a ProgressBar and use an animation to simulate the progress of an operation ?
       59.2How can I set the text as "Completed" in a progress bar at the end of progress?

    60. Controls Slider

      

       60.1How can I customize the Ticks on a Slider ?

    61. Controls Canvas

      

       61.1How can I use the attached properties of Canvas to position child elements ?
       61.2How do I position the children of a Canvas at a discreet X but stretch them vertically to fill?

    62. Controls Border

      

       62.1How do I draw a border outside the bounds of a control?
       62.2How can I animate the thickness of a border by using ThicknessAnimation ?
       62.3How can I use a BulletDecorator control that uses an image as the Bullet and a non-text element as the Child ?

    63. Controls Expander

      

       63.1How can I create an Expander with a ScrollViewer ?

    64. Controls GridSplitter

      

       64.1How can I make sure that a GridSplitter Is visible ?

    65. Controls Context Menu

      

       65.1How do I listen to click events on all the MenuItems through the parent ContextMenu?
       65.2How can I enable a Context Menu on a disabled Control ?
       65.3How do I bind the ContextMenu to a list of commands?

    66. Controls Popup

      

       66.1How can I animate a Popup ?

    67. Controls ToolTip

      

       67.1How do I use the TooltipService class?
       67.2Can I delay the display of a ToolTip ?
       67.3How do I include a delay only for the first tooltip and not for subsequent tooltips in my app?
       67.4How come I don't see a MouseHover event in WPF for it's elements?
       67.5How do I customize the style of a tooltip that gets shown ONLY on the CheckBoxes in my Window?

    68. Controls ItemsControl

      

       68.1How do I access the ItemsPresenter of a ListBox?
       68.2How do I filter out duplicate entries in my list when bound to a data source?

    69. Controls TreeView

      

       69.1How do I bind my tree to a hierarchical list?
       69.2I have a custom type called Group which has 2 collections Products and Services and I want both these collections to appear as siblings when the Groups collection is bound to a tree, how do I do that?
       69.3How do I bind a flat table/list containing self-referencing data to a TreeView to render it in a hierarchical view?
       69.4How do I listen to click events on all the tree nodes through the parent tree?
       69.5How do I bind my XML Data to the tree (the xml contains multi-level hierarchical data with leaf nodes at many levels)?
       69.6How do I bind a TreeView to a hierarchical list where some nodes have multiple child lists?
       69.7How do I obtain a reference to the child TreeViewItems of a parent TreeViewItem?

    70. Controls ComboBox

      

       70.1How do I add an item to the combo's choice list with value empty string in XAML?
       70.2What are the data sources I can bind the ComboBox's list to?
       70.3How do I bind the values of an enum to a ComboBox ?
       70.4How do I listen to text changed events in a ComboBox in editable mode?
       70.5Why do my SelectedValue bindings don't work in the ComboBox?

    71. Controls ListView

      

       71.1How do I create a single template and resue it for multiple columns in a ListView?
       71.2How do I access the ui element at a row/cell in my GridView?
       71.3How do I show tooltips for the listview items?
       71.4How do I move the focus to a ListViewItem that could also be out of view?
       71.5How do I color the bg of my ListView in GridView mode based on a "search" textbox where the user can enter search text?

    72. Controls ListBox

      

       72.1How do I bind a string array with a ListBox?
       72.2What are the data sources I can bind the ListBox to?
       72.3Why is the ListBox displaying the type name of the objects in the list instead of the value of a property in the object?
       72.4How do I bind the ListBox to a collection Property in my Window?
       72.5How do I make the items in the ListBox be a combination of values from 2 different columns in my data source?
       72.6How do I copy the contents of multiple selected items of a ListBox so that they fall in different lines in Excel and Notepad when pasted?
       72.7How do I display items in a ListBox horizontally?
       72.8How do I change the background of the selected item in the ListBox?
       72.9Why does the selection stay grayed out after I change the selection in the ListBox in the click of a button?

    © 2001-2010 Copyright Syncfusion Inc. All rights reserved.  |  Privacy Policy  |  Contact  |  Sitemap