Windows Forms FAQ

Syncfusion 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 email us.

Search Help
 

General

  • General
  • Concepts

  • Element Tree
  • Dependency Property
  • Attached Property
  • Routed Events
  • Resources.
  • Animation
  • Freezable Object
  • Input and Commands.
  • Layouts
  • XAML

  • Inline Styles and Templates
  • XML Namespaces
  • Code Behind
  • Custom Class
  • Type Converters
  • Content Model

  • ItemControl
  • HeaderedItemsControl
  • HeaderedContentControl
  • Content Control
  • Decorator Content Model
  • Panel Content Model
  • Documents

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

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

  • Adorners
  • Stylable controls
  • ControlTemplates
  • Data

  • Data Binding
  • DragandDrop
  • 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

  • ToolTip
  • TextBlock
  • TabControl
  • ProgressBar
  • PrintDialog
  • Popup
  • TextBox
  • Canvas
  • ComboBox
  • ListBox
  • StatusBar
  • ToolBar
  • Context Menu
  • Expander
  • DocumentViewer
  • FlowDocumentReader
  • GroupBox
  • GridSplitter
  • Image
  • Menu
  • ScrollBar
  • Slider
  • RichTextBox
  • Border
  • Buttons
  • 1. General

      

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

    2. Concepts Element Tree

      

       2.1How can I override the Logical Tree ?
       2.2How 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 use Dependency Property MetaData?
       3.3How can I register the default value of the State dependency property to be false?

    4. Concepts Attached Property

      

       4.1What is Attached Properties and how to register it?
       4.2How can I set an attached property in code?

    5. Concepts Routed Events

      

       5.1What is a Routed event?
       5.2How can I handle the input event through XAML?

    6. Concepts Resources.

      

       6.1How can I use an application resource ?

    7. Concepts Animation

      

       7.1What are the requirements for a property to be animated?
       7.2How do I trigger an animation when the data in the control is changed?
       7.3What is Path animation?

    8. Concepts Freezable Object

      

       8.1What is a Freezable?
       8.2How can I determine whether a Freezable Is Frozen?
       8.3How can I obtain a writable copy of a Read-Only Freezable?

    9. Concepts Input and Commands.

      

       9.1What is Commanding in WPF?
       9.2How do I create a CommandBinding using a RoutedCommand?
       9.3How can I add a CommandBinding to a window using markup?

    10. Concepts Layouts

      

       10.1When I try to add multiple controls to a button it shows an error, how do I add multiple controls to a button?
       10.2How placing controls in a WrapPanel differs from a Grid?

    11. XAML Inline Styles and Templates

      

       11.1How can I restrict the use of style ?
       11.2How can I create an extended style ?
       11.3How can I set a ControlTemplate ?
       11.4How 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?
       11.5What are the limitations of Inline Styles and Templates ?

    12. XAML XML Namespaces

      

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

    13. XAML Code Behind

      

       13.1What is the use of x:code ?

    14. XAML Custom Class

      

       14.1What way can a custom class can be defined in XAML?

    15. XAML Type Converters

      

       15.1How can I apply the TypeConverter Attribute?

    16. Content Model ItemControl

      

       16.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?
       16.2Can I create a ContentTemplate and apply the template to a ContentControl ?

    17. Content Model HeaderedItemsControl

      

       17.1How can I create a ControlTemplate for a HeaderedItemsControl ?

    18. Content Model HeaderedContentControl

      

       18.1How can I make a style for a ContentControl so that the control has an enhanced visual appearance ?

    19. Content Model Content Control

      

       19.1How can I get an enumerator to the ContentControl's logical child elements ?

    20. Content Model Decorator Content Model

      

       20.1How do I create a Borderless Window in WPF ?
       20.2How can I animate a BorderThickness value ?
       20.3How can I use Event Trigger to control a StoryBoard after it is started ?

    21. Content Model Panel Content Model

      

       21.1How do I add controls to Panel Content Model type of controls?

    22. Documents Serialization and Storage

      

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

    23. Documents Annotations

      

       23.1How can I Match Annotations with Annotated Objects ?
       23.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 ?

    24. Documents Flow Content

      

       24.1How can I define three paragraphs under one section ?
       24.2How can I use the BlockUIContainer element to host UIElement objects within Flow content ?
       24.3Can I embed a figure into a paragraph of text ?

    25. Documents Printing

      

       25.1How can I programmatically print XPS Files ?

    26. Graphics and Multimedia Rendering Graphics

      

       26.1How can I create a combine hard and soft shadow ?
       26.2How can I use a DoubleAnimation to rotate the textblock ?
       26.3What is the order in which the controls are rendered ?
       26.4How do I enumerate child objects in a visual tree ?
       26.5How rendering in WPF differs from WIN32 applications?

    27. Graphics and Multimedia Animation and Timing

      

       27.1When an animation is applied, the property value gets overwritten. How do we prevent the value of property ?
       27.2Performance gets reduced even after navigating away from a page that contains animation. How do we handle this issue ?
       27.3How do I apply an animation without using a storyboard ?

    28. Graphics and Multimedia 2D Graphics

      

       28.1How do I apply BitmapEffect to a particular area of an Image ?
       28.2How do I apply Transform when an event is occurred ?
       28.3In what way CombinedGeometry is used ?

    29. Graphics and Multimedia 3D Graphics

      

       29.1What are the properties that reduce the performance of a 3D graphics ?
       29.2How lights are useful in 3D graphics ?
       29.3How do I change the location of a model ?

    30. Graphics and Multimedia Visual Layer

      

       30.1How HitTest methods in VisualTreeHelper is useful ?
       30.2How do I use DrawingVisual object ?

    31. Control Customization Adorners

      

       31.1What is an adorner ?
       31.2Where can adorners be used ?
       31.3How to add a custom adorner ?
       31.4How do I bind an Adorner to an Element ?
       31.5How do I remove the Adorner from an element ?

    32. Control Customization Stylable controls

      

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

    33. Control Customization ControlTemplates

      

       33.1What is the use of a ControlTemplate ?
       33.2How to access elements that are embedded inside the ControlTemplate ?
       33.3How do I build an ItemsControl ControlTemplate ?
       33.4How to edit templates using Microsoft Expression Blend ?
       33.5How to get the default template of a control programmatically ?

    34. Data Data Binding

      

       34.1How to use binding in XAML ?
       34.2What is the use of the RelativeSource property ?
       34.3What is DataContext ? How is it used ?
       34.4Can ItemControl's Items and ItemsSource properties be modified simultaneously ?
       34.5How do I filter Items in an ItemControl when the ItemControl's ItemsSource is set to a datasource?
       34.6What are the uses of BindingModes?
       34.7How do I update the source as I type in a TextBox?
       34.8When an XMLDataProvider can be used ? What are it's specific uses ?
       34.9How does TwoWay BindingMode work in an XMLDataProvider?
       34.10In what way is an ObjectDataProvider useful?
       34.11How to pass a parameter to a constructor using ObjectDataProvider ?
       34.12How to pass a parameter to a function using ObjectDataProvider ?
       34.13How can I bind a method and pass a parameter to the method ?
       34.14How to Get or Set a value that indicates whether to include the DataErrorValidationRule ?

    35. Data DragandDrop

      

       35.1What are the objects involved in DragandDrop?
       35.2How do I create a DataObject?
       35.3How do I retrieve data from a DataObject ?

    36. Data Serialization

      

       36.1What is Serialization ?
       36.2How to write an IsolatedStorage to an XML file ?
       36.3How do I serialize objects to a binary file ?

    37. Globalization and Localization Attributes

      

       37.1What are the three types of Localizability Attributes and how to use them ?
       37.2How can I set the Language property to the current user's UI language ?
       37.3How can I set the substitution property by overriding the default substitution ?

    38. Globalization and Localization Comments

      

       38.1How can I specify in the .proj file whether to leave the free-form localization comments in the assembly using LocalizationDirectivesToLocFile tag ?
       38.2How can I add localization comments to an XAML file ?

    39. Globalization and Localization Globalization Struc

      

       39.1Can I override the default categories for platform controls in XAML as well ?
       39.2How can I automatically layout Grids Using the IsSharedSizeScope Property ?

    40. Application and Deployment ClickOnce

      

       40.1How does ClickOnce deployment work ?
       40.2Can I add prerequisites in my ClickOnce deployment ?
       40.3How do I enable automatic updates for my application using ClickOnce deployment ?

    41. Application and Deployment Frame

      

       41.1What is the difference between Frame and NavigationWindow ?
       41.2How does Rendering work in Frame control ?
       41.3Can I add dynamic HTML content to a Frame control ?

    42. Application and Deployment Page

      

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

    43. Application and Deployment Navigation

      

       43.1How to set content of a NavigationWindow ?
       43.2How do I handle Back and Forward button click ?
       43.3How do I pass data between pages in a NavigationWindow ?

    44. Application and Deployment Setup

      

       44.1How do I add registry entries in a setup project ?
       44.2How do I deploy shared components ?
       44.3How launch conditions are useful and how to add one to a setup project ?

    45. Application and Deployment Window

      

       45.1How do I create a child window in WPF ?
       45.2How do I host Windows Forms control in a WPF Window ?
       45.3Does WPF support MDI ?

    46. Interoperability Message Loops Between

      

       46.1How can I write Message Loops ?
       46.2How can I HwndSource Treats ComponentDispatcher Events ?
       46.3How can I set the Owner property of the WPF window to the handle of our main form using helper class ?

    47. Interoperability Win32 in WPF

      

       47.1How can I use Windows Forms in a WPF application ?
       47.2How do I host a Windows Forms control in a WPF application ?
       47.3How can I leverage my current investment in Windows Forms applications and still tap into the cool features of WPF ?
       47.4How can I host a Windows Forms Composite Control in Windows Presentation Foundation ?

    48. Interoperability WPF in Win32

      

       48.1How do I host a WPF control in a Windows Forms application?
       48.2How can I Host the WPF UserControl in Windows Forms ?
       48.3What is the procedure to host the WPF content in Win32 window ?

    49. Interoperability Windows Forms and WPF

      

       49.1Will you provide a tool to convert Windows Forms applications to WPF applications ?
       49.2What about user controls and third-party controls including ActiveX controls?
       49.3Where do I find System.Windows.Forms.Integration ?
       49.4Can I use a WindowsFormsHost element to host a System.Windows.Forms ?

    50. Security Trusted Security

      

       50.1How do I assign full trust to an XBAP application ?
       50.2I am able to access the registry using full trust XBAP application in debug mode, when hosted in an intranet, the application gets crashed. What do I do?
       50.3How do I get a custom defined permission set of an XBAP application ?

    51. Security Partial Trust Security

      

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

    52. Tools Microsoft Expression Blend

      

       52.1Can a WPF application be designed using Microsoft Expression Blend ?
       52.2How do I add animations using Microsoft Expression Blend ?
       52.3How do I add custom controls to an application using Microsoft Expression Blend ?

    53. Tools ZAM3D

      

       53.1What is ZAM3D ?
       53.2What are the file formats supported by ZAM3D ?
       53.3Can an XAML file created using ZAM3D be used with Visual Studio.NET ?

    54. Tools XAMLPAD

      

       54.1What is XAMLPAD ?
       54.2Does XAMLPAD support custom controls ?
       54.3Can we see the output of an XAML using XAMLPAD ?

    55. Controls ToolTip

      

       55.1Can I delay the display of a ToolTip ?
       55.2How can I use the ToolTipService properties to specify the position of a tooltip whose content is not a ToolTip object ?
       55.3Can I use the BetweenShowDelay Property ?

    56. Controls TextBlock

      

       56.1How can I make a TextBlock editable when it is clicked and the value is committed when ESC or ENTER is pressed?

    57. Controls TabControl

      

       57.1How do I prevent the user from changing the selected tab page in a TabControl ?
       57.2How do I dynamically hide and unhide tabs in a TabControl ?
       57.3How do I make the tabs in a TabControl appear on the bottom instead of the right?
       57.4How can I add a style to a TabItem that is used in the TabControl ?

    58. Controls ProgressBar

      

       58.1How can I create a ProgressBar and use an animation to simulate the progress of an operation ?
       58.2How can I make the text changed by itself during progress?

    59. Controls PrintDialog

      

       59.1How can I create and display a PrintDialog ?
       59.2How do I display the PrintPreview as a maximized window and control it's zooming ?

    60. Controls Popup

      

       60.1How can I animate a Popup ?
       60.2How can I specify a Custom Popup Position ?

    61. Controls TextBox

      

       61.1How do I format numbers, dates and currencies in a TextBox ?
       61.2How do I make a TextBox use all upper-case (or lower-case) characters ?
       61.3How do I support browsing for a text file and reading it into a TextBox?

    62. Controls Canvas

      

       62.1How can I use the attached properties of Canvas to position child elements ?

    63. Controls ComboBox

      

       63.1How do I fill a ComboBox with the available fonts ?
       63.2How do I bind the values of an enum to a ComboBox ?

    64. Controls ListBox

      

       64.1How do I bind a string array with a ListBox?
       64.2How do I display items in a ListBox horizontally?

    65. Controls StatusBar

      

       65.1How do I create custom layout for StatusBar items?

    66. Controls ToolBar

      

       66.1How do I determine which button in a ToolBar is clicked ?
       66.2How can I apply a Style to a Menu control on a ToolBar ?
       66.3When I tab into a toolbar in WPF I can't tab out again ? What can I do to change this tab behavior ?

    67. Controls Context Menu

      

       67.1How do I make the Context Menu appear only when clicked at certain portions of the Control ?
       67.2How can I enable a Context Menu on a disabled Control ?
       67.3How can I create a shared Context Menu ?
       67.4How do I make the Context Menu to close after a set time interval?

    68. Controls Expander

      

       68.1How can I create an Expander with a ScrollViewer ?
       68.2How can I bind the Expander's header element's Width to the ActualWidth of the Expander ?
       68.3How do I make the Expander button to be justified to the right, rather than the left which is the default ?

    69. Controls DocumentViewer

      

       69.1How can I replace the style of a DocumentViewer ?
       69.2How can I extend the style of a DocumentViewer ?
       69.3How can I DataBind DocumentViewer's Zoom Property to a TextBox ?
       69.4How to load an XPS document into the DocumentViewer?

    70. Controls FlowDocumentReader

      

       70.1How can I load an XAML file into a FlowDocumentReader?
       70.2How can I save the contents of a FlowDocumentReader as an XAML file ?

    71. Controls GroupBox

      

       71.1How can I create a GroupBox that has a title and a visible border that encloses it's content ?

    72. Controls GridSplitter

      

       72.1How can I make sure that a GridSplitter Is visible ?
       72.2How can I create and use a GridLengthConverter Object ?

    73. Controls Image

      

       73.1How can I convert an Image to grayscale ?
       73.2How can I crop an Image ?
       73.3Why does adding images to an ImageList in the Designer cause them to lose their alpha channel ?
       73.4How to rotate an image ?
       73.5How do I access / edit the metadata associated with an Image ?
       73.6How can the DrawVisual be used for rendering images ?

    74. Controls Menu

      

       74.1How do I enable the mnemonics (underlines) being displayed when an application is launched ?
       74.2How can I style a Separator used as a Menu Item ?

    75. Controls ScrollBar

      

       75.1How can I use the member values of the enumeration to set the HorizontalScrollBarVisibility property of the ScrollViewer control ?
       75.2How can I use the Content-Scrolling Methods of ScrollViewer ?

    76. Controls Slider

      

       76.1How can I customize the Ticks on a Slider ?
       76.2Can I bind two sliders in two different windows ?

    77. Controls RichTextBox

      

       77.1How do I add a hyperlink to a RichTextBox control ?
       77.2How do I create and save a RichTextFormat (RTF) file?
       77.3How do I support drag-and-drop for a RichTextBox?
       77.4How can I Save, Load, and Print RichTextBox Content ?