Windows Presentation Foundation (WPF) Interview Questions and Answers

What is WPF? Windows Presentation Foundation (WPF) is a next-generation presentation system for building Windows client applications with visually stunning user experiences. With WPF, you can create a wide range of both standalone and browser-hosted applications.
What is a WPF Animation?
Windows Presentation Foundation (WPF) is a next-generation application development tool that ties together many different technologies: document data, audio, video, 2D/3D graphic rendering, etc. It has the ability to perform animation on the objects available, and this article will show some of the various animations that can be performed.
Prior to WPF, Microsoft Windows developers had to create and manage their own timing systems or use special custom libraries. WPF includes an efficient timing system that is exposed through managed code and Extensible Application Markup Language (XAML) and that is deeply integrated into the WPF framework. WPF animation makes it easy to animate controls and other graphical objects.
WPF handles all the behind-the-scenes work of managing a timing system and redrawing the screen efficiently. It provides timing classes that enable you to focus on the effects you want to create, instead of the mechanics of achieving those effects. WPF also makes it easy to create your own animations by exposing animation base classes from which your classes can inherit, to produce customized animations. These custom animations gain many of the performance benefits of the standard animation classes.
Creating animations in WPF is easier than it sounds. No explicit use of timers is required, in fact you can create many useful animations using pure markup (XAML). Perhaps the best use of animations is to spice up UI. Most properties of objects can be animated (e.g. width, height, color, position, etc). Want your button to fade to a new color when a user mouses over it? Want your text to quickly slide into view rather than just abruptly appear? Of course once you see how easy WPF animations are you might be in danger of overdoing it and creating some truly garish and annoying apps but that's why you like programming.
Here is an overview of WPF Animation. Have a look and explore yourself. http://msdn.microsoft.com/en-us/library/ms752312.aspx
How to host a WPF application in a browser?
XAML browser applications (XBAPs) combines features of both Web applications and rich-client applications. Like Web applications, XBAPs can be published to a Web server and launched from Internet Explorer. Like rich-client applications, XBAPs can take advantage of the capabilities of WPF. Developing XBAPs is also similar to rich-client development. This topic provides a simple, high-level introduction to XBAP development and underscores where XBAP development is different than standard rich-client development.
Windows Presentation Foundation (WPF) Host (PresentationHost.exe) is the application that enables WPF applications to be hosted in compatible browsers (including Microsoft Internet Explorer 6 and later). By default, Windows Presentation Foundation (WPF) Host is registered as the shell and MIME handler for browser-hosted WPF content, which includes:
  • Loose (uncompiled) XAML files (.xaml).
  • XAML browser application (XBAP) (.xbap). For files of these types, Windows Presentation Foundation (WPF) Host:
  • Launches the registered HTML handler to host the Windows Presentation Foundation (WPF) content.
  • Loads the right versions of the required common language runtime (CLR) and Windows Presentation Foundation (WPF) assemblies.
  • Ensures the appropriate permission levels for the zone of deployment are in place.
For More Information:
http://msdn.microsoft.com/en-us/library/aa970060.aspx
http://msdn.microsoft.com/en-us/library/aa970051.aspx

What is XAML?
XAML is used extensively in .NET Framework 3.0 technologies, particularly in Windows Presentation Foundation (WPF) . In WPF, XAML is used as a user interface markup language to define UI elements, data binding, eventing, and other features. In WF, workflows can be defined using XAML. XAML elements map directly to common language runtime object instances, while XAML attributes map to Common Language Runtime properties and events on those objects. XAML files can be created and edited with visual design tools such as Microsoft Expression Blend, Microsoft Visual Studio, and the hostable Windows Workflow Foundation visual designer.
Can XAML meant only for WPF?
Show/Hide AnswerNo,XAML is not meant only for WPF.XAML is a XML-based language and it had various variants.
WPF XAML is used to describe WPF content, such as WPF objects, controls and documents. In WPF XAML we also have XPS XAML which defines an XML representation of electronic documents.
Silverlight XAML is a subset of WPF XAML meant for Silverlight applications. Silverlight is a cross-platform browser plug-in which helps us to create rich web content with 2-dimensional graphics, animation, and audio and video.
WWF XAML helps us to describe Windows Workflow Foundation content. WWF engine then uses this XAML and invokes workflow accordingly.
How to Create a collection in XAML?
If you have a custom collection definition, you could use it directly in XAML syntax. This produces more readable XAML. Here, a ComposerCollection has been defined in code and is used as follows:
    <custom:ComposerCollection x:Key="ComposerCollection">
      <custom:Composer Name="Mozart, Wolfgang Amadeus" Birth="1756"/>
      <custom:Composer Name="Górecki, Henryk Mikolaj" Birth="1933"/>
      <custom:Composer Name="Massenet, Jules" Birth="1842"/>
    </custom:ComposerCollection>
    
What is XBAP?
XBAP stands for XAML Browser Application. XBAP allows for WPF applications to be used inside a browser. The .NET framework is required to be installed on the client system. Hosted applications run in a partial trust sandbox environment. They are not given full access to the computer’s resources and not all of WPF functionality is available.WPF supports the creation of applications that run directly in a web browser. (So will WPF/E, when it is released.) They are called XAML Browser Applications (XBAPs), and have a .xbap file extension.
The power of this WPF support is that the exact same programming model is used for a XAML Browser Application as for a standard Windows application. Therefore, creating an XBAP isn’t much different than creating a standard Windows application. The maindifferences are as follows:
  • Not all features in WPF or the .NET Framework are accessible (by default).
  • Navigation is integrated into the browser (for Internet Explorer 7 or later).
  • Deployment is handled differently.
What is BAML?
BAML, which stands for Binary Application Markup Language, is simply XAML that has been parsed, tokenized, and converted into binary form. Although any chunk of XAML can be represented by procedural code, the XAML-to-BAML compilation process does not generate procedural source code. So, BAML is not like Microsoft intermediate language (MSIL); it is a compressed declarative format that is faster to load and parse (and smaller in size) than plain XAML. BAML is just an implementation detail of the XAML compilation process without any direct public exposure, so it could be replaced with something different in the future. Nevertheless, it’s interesting to be aware of its existence.
What kind of documents are supported in WPF?
There are two kind of major document supported in WPF:
  • Fixed format documents
  • Flow format document
Fixed format documents look like PDF format. They display content regardless of screen size and resolution.
Flow format document adjust depending on screen size and resolution.

How can we access XAML objects in behind code?
To access XAML objects in behind code you just need to define them with the same name as given in the XAML document.
Name the Implicit .NET Namespaces in WPF?
WPF maps all of the following .NET namespaces:
- System.Windows
- System.Windows.Automation
- System.Windows.Controls
- System.Windows.Controls.Primitives
- System.Windows.Data
- System.Windows.Documents
- System.Windows.Forms.Integration
- System.Windows.Ink
- System.Windows.Input
- System.Windows.Media
- System.Windows.Media.Animation
- System.Windows.Media.Effects
- System.Windows.Media.Imaging
- System.Windows.Media.Media3D
- System.Windows.Media.TextFormatting
- System.Windows.Navigation
- System.Windows.Shapes
Name the built-in markup extensions in WPF?
The following are the built-in markup extensions:
1) Binding:-To bind the values of two properties together.
2) StaticResource:-One time lookup of a resource entry
3) DynamicResource:-Auto updating lookup of a resource entry
4) TemplateBinding:-To bind a property of a control template to a dependency property of the control
5) x:Static:-Resolve the value of a static property.
6) x:Null:-Return null
What is observableCollection in WPF?
In many cases the data that you work with is a collection of objects. For example, a common scenario in data binding is to use anItemsControl such as a ListBox, ListView, or TreeView to display a collection of records. You can enumerate over any collection that implements the IEnumerable interface. However, to set up dynamic bindings so that insertions or deletions in the collection update the UI automatically, the collection must implement the INotifyCollectionChanged interface. This interface exposes the CollectionChanged event, an event that should be raised whenever the underlying collection changes.
WPF provides the ObservableCollection(T) class, which is a built-in implementation of a data collection that implements theINotifyCollectionChanged interface. Before implementing your own collection, consider using ObservableCollection(T) or one of the existing collection classes, such as List(T),Collection(T), and BindingList(T), among many others. If you have an advanced scenario and want to implement your own collection, consider using IList, which provides a non-generic collection of objects that can be individually accessed by index. Implementing IList provides the best performance with the data binding engine.
What are the three kinds of routed events in WPF and how do they differ?
Routed events in WPF are direct, tunneling a bubbling. A direct event can be raised only by the element in which it originated. A bubbling event is raised first by the element in which it originates and then is raised by each successive container in the visual tree. A tunneling event is raised first by the topmost container in the visual tree and then down through each successive container until it is finally raised by the element in which it originated. Tunneling and bubbling events allow elements of the user interface to respond to events raised by their contained elements.
What is the difference between Navigation applicaton and XBAPs in WPF?
While both are page-based applications. Navigation Page application are used for navigation applicated hosted with full trust policy that makes them ideal for deployment in secure environment. XBAPs are generally design for Window Explorer and are not locally installed. They are partial trust application restricted to use local file system, Database, registries and other sensitive resources and this makes them ideal for wide distribution
Can we define WPF in a precise way?
Windows Presentation Framework is the new presentation API. WPF is a two and three dimensional graphics engine. It has the following capabilities:
  • Has all equivalent common user controls like buttons, check boxes sliders etc.
  • Fixed and flow format documents
  • Has all of the capabilities of HTML and Flash
  • 2D and 3D vector graphics
  • Animation
  • Multimedia
  • Data binding

WPF has replaced DirectX?
No, WPF does not replace DirectX. DirectX will still be still needed to make cutting edge games. The video performance of directX is still many times higher than WPF API. So when it comes to game development the preference will be always DirectX and not WPF. WPF is not a optimum solution to make games, oh yes you can make a TIC TAC TOE game but not high action animation games.
One point to remember WPF is a replacement for windows form and not directX.
Entry Level
  • Strong .NET 2.0 Background & willing to learn!
  • Explain dependency properties?
  • What’s a style?
  • What’s a template?
  • Binding
  • Differences between base classes: Visual, UIElement, FrameworkElement, Control
  • Visual vs Logical tree?
  • Property Change Notification (INotifyPropertyChange and ObservableCollection)
  • ResourceDictionary – Added by a7an
  • UserControls – Added by a7an
  • difference between bubble and tunnel routing strategies – added by Carlo
Mid-level
  • Routed Events & Commands
  • Converters – Added by Artur Carvalho
  • Explain WPF’s 2-pass layout engine?
  • How to implement a panel?
  • Interoperability (WPF/WinForms)
  • Blend/Cider – Added by a7an
  • animations and storyboarding
  • ClickOnce Deployment
  • Skinning/Themeing
  • Custom Controls
  • How can worker threads update the UI?
Senior
  • Example of attached behavior?
  • What is PRISM,CAL & CAG?
  • How can worker threads update the UI?
  • WPF 3D – Added by a7an
  • Differences between Silverlight 2 and WPF
  • MVVM/MVP – Added by a7an
  • WPF Performance tuning
  • Pixel Shaders
  • Purpose of Freezables
What are dependency properties?
These dependency properties belong to one class but can be used in another. Consider the below code snippet:-
    <Rectangle Height="72" Width="131" Canvas.Left="74" Canvas.Top="77" />

Height and Width are regular properties of the Rectangle. But Canvas. Top and Canvas. Left is dependency property as it belongs the canvas class. It is used by the Rectangle to specify its position within Canvas.

When should I use WPF instead of DirectX?
DirectX is definitely not dead and is still more appropriate than WPF for advanced developers writing hard-core “twitch games” or applications with complex 3D models where you need maximum performance. That said, it’s easy to write a naive DirectX application that performs far worse than a similar WPF application. DirectX is a low-level interface to the graphics hardware that exposes all of the quirks of whatever GPU a particular computer has. DirectX can be thought of as assembly language in the world of graphics: You can do anything the GPU supports. WPF provides a high-level abstraction that takes a description of your scene and figures out the best way to render it, given the hardware resources available. Internally, this might involve using Shader Model 3.0, or the fixed-function pipeline, or software. (Don’t worry if you’re not familiar with these terms, but take it as a sign that you should be using WPF!).
The downside of choosing DirectX over WPF is a potentially astronomical increase in development cost. A large part of this cost is the requirement to test your application on each driver/GPU combination you intend to support. One of the major benefits of building on top of WPF is that Microsoft has already done this testing for you! You can instead focus your testing on low-end hardware for measuring performance. The fact that WPF applications can even leverage the client GPU over Remote Desktop or in a partial-trust environment is also a compelling differentiator.
When should I use WPF instead of Windows Forms?
WPF is clearly more suitable for applications with rich media, but some people have said that Windows Forms is the best choice for business applications with traditional user interfaces. I think this belief is based on first versions of WPF in which many standard controls didn’t exist (such as TreeView, ListView, and OpenFileDialog) and a visual designer didn’t exist, making traditional Windows application development in WPF harder than in Windows Forms. Although Windows Forms still has useful controls that WPF lacks (such as DataGridView and PropertyGrid) and at the time of writing has a larger set of third-party controls in the marketplace, WPF has compelling features even for traditional user interfaces (such as the support for resolution independence or advanced layout).
When should I use WPF instead of Adobe Flash?
For creating rich web content, Flash is currently the most popular option because of its ubiquity.
You can put Flash-based content on a website with confidence that the overwhelming majority of visitors already have the necessary player installed. (And if they don’t, it’s a very quick download.) WPF applications can also run within a web browser. WPF has the advantage of better development tools and programming model, a richer feature set, robust control reuse, broad programming language support, and full access to the underlying platform (when security permits). But viewing such content requires Windows and the .NET Framework 3.0 (installed by default on Windows Vista or later).
How do I get a ToolTip to appear when hovering over a disabled element?
use the ShowOnDisabled attached property of the ToolTipService class! From
XAML, this would look like the following on a Button:
Or from C# code, you can call the static method corresponding to the attached property:
ToolTipService.SetShowOnDisabled(myButton, true);
How can I forcibly close a ToolTip that is currently showing?
Set its IsOpen property to false.
When the SelectionChanged event gets raised, how do I get the new selection?
The SelectionChanged event is designed to handle controls that allow multiple selections, so it can be a little confusing for a single-selection selector such as ComboBox. The SelectionChangedEventArgs type passed to event handlers has two properties of type IList: AddedItems and RemovedItems. AddedItems contains the new selection and RemovedItems contains the previous selection.
e.g.
    void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        if (e.AddedItems.Count > 0)
        object newSelection = e.AddedItems[0];
    }
                    
Like this code, never assume that there’s a selected item! Besides the fact that ComboBox’s selection can be cleared programmatically, it can get cleared by the user when IsEditable is true and IsReadOnly is false. In this case, if the user changes the selection box text to something that doesn’t match any item, the SelectionChanged event is raised with an empty AddedItems collection.

Why should I bother wrapping items in a ComboBoxItem?
ComboBoxItem exposes some useful properties—IsSelected and IsHighlighted—and useful events—Selected and Unselected. Using ComboBoxItem also avoids a quirky behavior with showing content controls in the selection box (when IsEditable is false): If an item in a ComboBox is a content control, the entire control doesn’t get displayed in the selection box. Instead, the inner content is extracted and shown. By using ComboBoxItem as the outermost content control, the inner content is now the entire control that you probably wanted to be displayed in the first place. Because ComboBoxItem is a content control, it is also handy for adding simple strings to a ComboBox (rather than using something like TextBlock or Label).
How can I make ListBox arrange its items horizontally instead of vertically?
One way is to define a new control template, but all ItemsControls provide a shortcut with its ItemsPanel property. ItemsPanel enables you to swap out the panel used to arrange items while leaving everything else about the control intact. ListBox uses a panel called VirtualizingStackPanel to arrange its items vertically, but the following code replaces it with a new VirtualizingStackPanel that explicitly sets its Orientation to Horizontal:
The translation of this XAML to procedural code is not straightforward, but here’s how you can accomplish the same task in C#:
    FrameworkElementFactory panelFactory =
    new FrameworkElementFactory(typeof(VirtualizingStackPanel));
    panelFactory.SetValue(VirtualizingStackPanel.OrientationProperty,
    Orientation.Horizontal);
    myListBox.ItemsPanel = new ItemsPanelTemplate(panelFactory);
    
How can I get ListBox to scroll smoothly?
By default, ListBox scrolls on an item-by-item basis. Because the scrolling is based on each item’s height, it can look quite choppy if you have large items. If you want smooth scrolling, such that each scrolling action shifts the items by a small number of pixels regardless of their heights, the easiest solution is to set the ScrollViewer.CanContentScroll attached property to false on the ListBox. Be aware, however, that by making this change you lose ListBox’s virtualization functionality. Virtualization refers to the optimization of creating child elements only when they become visible on the screen. Virtualization is only possible when using data binding to fill the control’s items, so setting CanContentScroll to false can negatively impact the performance of data-bound scenarios only.
How do I get the items in my ItemsControl to have Automation IDs, as seen in tools like UISpy?
The easiest way to give any FrameworkElement an Automation ID is to set its Name property, as that gets used by default for automation purposes. However, if you want to give an element an ID that is different from its name, simply set the AutomationProperties.AutomationID attached property (from the System.Windows.Automation namespace) to the desired string.
How can I get items in a StatusBar to grow proportionally?
It’s common to want StatusBar panes that remain proportionately sized. For example, perhaps you want a left pane that occupies 25% of the StatusBar’s width and a right pane that occupies 75% of the width. This can be done by overriding StatusBar’s ItemsPanel with a Grid and configuring the Grid’s columns appropriately.
How can I make TextBox support multiple lines of text?
Setting AcceptsReturn to true allows users to press the Enter key to create a new line of text. Note that TextBox always supports multiple lines of text programmatically. If its Text is set to a string containing NewLine characters, it displays the multiple lines regardless of the value of AcceptsReturn. Also, the multiline support is completely independent from text wrapping. Text wrapping only applies to individual lines of text that are wider than the TextBox.
What unit of measurement is used by WPF?
All absolute measurements, such as the numbers used in this section’s size-related properties, are specified in device-independent pixels. These “logical pixels” are meant to represent 1/96th of an inch, regardless of the screen’s DPI setting. Note that device-independent pixels are always specified as double values, so they can be fractional.
The exact measurement of 1/96th of an inch isn’t important, although it was chosen because on a typical 96 DPI display, one device-independent pixel is identical to one physical pixel. Of course, the notion of a true “inch” depends on the physical display device. If an application draws a one-inch line on my laptop screen, that line will certainly be longer than one inch if I hook up my laptop to a projector!
Where’s the entry point in WPF application?
When you create a WPF Windows Application in Visual Studio, the generated project has no Main method, yet it still runs as expected! In fact, even attempting to add a Main method gives a compilation error telling you that it is already defined.
Application is special-cased when it is compiled from XAML, because Visual Studio assigns the XAML file a Build Action of ApplicationDefinition. This causes a Main method to be autogenerated.
How do I retrieve command-line arguments in my WPF application?
Command-line arguments are typically retrieved via a string array parameter passed to Main, but the common way to define WPF applications doesn’t allow you to implement the Main method. You can get around this in two different ways. One way is to forego defining an Application-derived class in XAML, so you can manually define the Main method with a string array parameter. The easier way, however, is to simply call System.Environment.GetCommandLineArgs at any point in your application, which returns the same string array you’d get inside Main.
Can BAML be decompiled back into XAML?
Sure, because an instance of any public .NET class can be serialized as XAML, regardless of how it was originally declared. The first step is to retrieve an instance that you want to be the root. If you don’t already have this object, you can call the static System.Windows.Application.LoadComponent method as follows:
    System.Uri uri = new System.Uri(“MyWindow.xaml”, System.UriKind.Relative);
    Window window = (Window)Application.LoadComponent(uri);
    
This differs from previous code that uses FileStream to load a .xaml file because with LoadComponent, the name specified as the Uniform Resource Identifier (URI) does not have to physically exist as a standalone .xaml file. LoadComponent can automatically retrieve BAML embedded as a resource when given the appropriate URI (which, by MSBuild convention, is the name of the original XAML source file). In fact, Visual Studio’s autogenerated InitializeComponent method calls Application.LoadComponent to load embedded BAML, although it uses a different overload. After you’ve gotten a hold of the root element instance, you can use the System.Windows.Markup.XamlWriter class to get a XAML representation of the root element (and, therefore, any of its children). XamlWriter contains five overloads of a static Save method, the simplest of which accepts an object instance and returns appropriate XAML as a string. For example:
string xaml = XamlWriter.Save(window);
It might sound a little troubling that BAML can be so easily “cracked open,” but it’s really no different from any other software running locally or displaying UI locally. (For example, you can easily dig into a website’s HTML, JavaScript, and Cascading Style Sheets [CSS] files.)

What are possible ways to implement distributed applications in .NET?
.NET Remoting and ASP.NET Web Services.
Can you create Windows Service Using WPF?
No, you can not build the windows Services using WPF. WPF is presentation technolgy, where as Windows service requires certain permission to perform the certain GUI retalted operations.
If the Windows service does not have the appropriate permissions, there may be unexpected results.
What is a Routed event?
In a typical WPF application, it contains many elements. These elements exist in an element tree relationship with each other. A routed event is a type of event that can invoke handlers on multiple listeners in an element tree, rather than just on the object that raised the event.
How to Change the BackGround Color of a Button dynamically in WPF?
System.Windows.Controls.Button b = new System.Windows.Controls.Button();
b.Content = "OK";
b.Background = System.Windows.Media.Brushes.Red;

How to use MediaPlayer to play an audio file in WPF?
MediaPlayer player = new MediaPlayer();
player.Open(new Uri("music.wma", UriKind.Relative));
player.Play();
How to use SoundPlayer to play a sound in WPF?
The following code shows how to use SoundPlayer to play a sound:
SoundPlayer player = new SoundPlayer("tada.wav");
player.Play();
Why is Shape.Stroke a Brush rather than a Pen in WPF?
Shape's Fill and Stroke properties have the same role as GeometryDrawing's Brush and Pen properties: Fill is for the inner area, and Stroke is for the outline. Internally, a Pen is indeed used to create the outline of the Shape. But rather than exposing the Pen directly, Shape defines Stroke as a Brush and exposes eight additional properties to tweak the settings of the internal Penwrapping the Stroke Brush: StrokeStartLineCap,StrokeEndLineCap, StrokeThickness, and so on.
This unfortunate inconsistency was created because setting the Pen-related properties directly on the Shape is simpler than using a separate Pen object, especially for the common case in which all you're setting is the Brush and the Thickness.
Name the classes that derive from the abstract System.Windows.Shapes.Shape class in WPF?
1) Rectangle
2) Ellipse
3) Line
4) Polyline
5) Polygon
6) Path
What's the difference between PenLineCap's Flat and Square values?
A Flat line cap ends exactly on the endpoint, whereas a Square line cap extends beyond the endpoint. Similar to the Round line cap, you can imagine a square with the same dimensions as the Pen's Thickness centered on the endpoint. Therefore, the line ends up extending half the length of the Pen's Thickness.
What is the differenece between System.Windows.dll and System.Windows.Browser.dll?
1) System.Windows.dll:-This Assembly includes many of the classes for building Silverlight user interfaces,including basic elements,Shapes and Brushes,classes that support animation and databinding,and the version of the FileOpenDialog that works with isolated storage.
2) System.Windows.Browser.dll:-This Assembly contains classes for interacting with HTML Elements.
Name the ToolTipService timing properties in WPF?
The following ToolTipService timing properties are only defined for the ToolTipService class and are used by all tooltips:
1) InitialShowDelay
2) ShowDuration
3) BetweenShowDelay
In Which NameSpace 'Content' Controls are derived from?
'Content' Controls are derived from System.Windows.Controls.ContentControl
Name the Types of Triggers in WPF?
There are three types of triggers in WPF:
1)Property Triggers - run when the value of a dependency property changes.
2)Data Triggers - run when the value of any .NET property changes, using data binding.
3)Event Triggers - run when a routed event occurs.
Name the types of Columns that are available in WPF DataGrid?
1) DataGridTextColumn
2) DataGridCheckBoxColumn
3) DataGridComboBoxColumn
4) DataGridHyperlinkColumn
5) DataGridTemplateColumn
Name the Classes that contains arbitrary content in WPF?
1)ContentControl:- A single arbitrary object.
2)HeaderedContentControl:- A header and a single item, both of which are arbitrary objects.
3)ItemsControl:- A collection of arbitrary objects.
4)HeaderedItemsControl:- A header and a collection of items, all of which are arbitrary objects.
Name the Events that are implemented by NavigationService?
1) Navigating:- Occurs when a new navigation is requested. Can be used to cancel the navigation.
2) NavigationProgress:- Occurs periodically during a download to provide navigation progress information.
3) Navigated:- Occurs when the page has been located and downloaded.
4) NavigationStopped:- Occurs when the navigation is stopped (by calling StopLoading), or when a new navigation is requested while a current navigation is in progress.
5)NavigationFailed:- Occurs when an error is raised while navigating to the requested content.
6) LoadCompleted:- Occurs when content that was navigated to is loaded and parsed, and has begun rendering.
7) FragmentNavigation:- Occurs when navigation to a content fragment begins, which happens:
a. Immediately, if the desired fragment is in the current content.
b. After the source content has been loaded, if the desired fragment is in different content.
What is the default Orientation of Stack Panel?
The Default Orientation of Stack Panel is 'Vertical'.
What are the major subsystems of the Windows Presentation Foundation?
1) Object
2) Threading.DispatcherObject
3) Windows.DependancyObject
4) Windows.Media.Visuals
5) Windows.UIElements
6) Windows.FrameworkElement
7) Windows.Controls.Control
In Which NameSpace you will find a 'Popup' and 'Thumb' control in WPF?
In 'system.windows.controls.primitives' namespace
Name Some Methods of MediaElement in WPF?
MediaElement has the following methods :-
1) Play: Plays media from the current position.
2) Stop: Stops and resets media to be played from the beginning.
3) Pause: Pauses media at the current position.
4) Close: Closes the media.
How to Set Window Title Bar Name at RunTime in WPF?
this.Title="TitleName";
In Which of the Following Definitions element you will find a 'Width' and 'Height' of a Grid(TAG)?
1) <Grid.RowDefinitions >
2) <Grid.ColumnDefinitions>

In <Grid.RowDefinitions > you will find a 'Height'
eg: <Grid.RowDefinitions >
<RowDefinition Height="50" />
</Grid.RowDefinitions>
In <Grid.ColumnDefinitions> you will find a 'Width'
eg:<Grid.ColumnDefinitions>
<ColumnDefinition Width="90" />
</Grid.ColumnDefinitions>
What are the Features of WPF?
The Features of WPF are:-

1)Device Independent Pixel (DPI).
2)Built-In Support for Graphics and Animation.
3)Redefine Styles and Control Templates.
4)Resource based Approach for every control.
5)New Property System & Binding Capabilities.
Why WPF is used?
Windows Presentation Foundation (WPF):WPF is used to develop elaborate user interfaces like those that adorn Windows Vista and managed advanced media streaming and integration. WPF is the a complete revamp of Windows Forms so that user interface, graphic, and media development is now designed around the .NET Framework.
Name the Layout Panels of WPF?
These are the five most layout panels of WPF:
1)Grid Panel
2)Stack Panel
3)Dock Panel
4)Wrap Panel
5)Canvas Panel
What are the difference between CustomControls and UserControls in WPF?
CustomControl (Extending an existing control):
1) Extends an existing control with additional features.
2) Consists of a code file and a default style in Themes/Generic.xaml.
3) Can be styled/templated.
4) The best approach to build a control library.
UserControl (Composition):
1) Composes multiple existing controls into a reusable "group".
2) Consists of a XAML and a code behind file.
3) Cannot be styled/templated.
4) Derives from UserControl.
What are the Advantages of XAML?
1)XAML code is short and clear to read.
2)Separation of designer code and logic.
3)Graphical design tools like Expression Blend require XAML as source.
4)The separation of XAML and UI logic allows it to clearly separate the roles of designer and developer.
Which class of the WPF is the base class of all the user-interactive elements?
Control class is the base class of all the user-interactive elements in WPF.
Which class is the base class of all the visual elements of WPF?
'Visual' is the base class of all the visual elements of WPF.
Control class of WPF is derived from which class?
Control class of WPF is derived from FrameworkElement class.
The core classes for User Interface is located in which namespace?
System.Windows.Shapes namespace defines UI classes like Line, Rectangle,etc.
Which namespace provide classes to work with images, sound, video, etc?
The System.Windows.Media namespace provide classes to work with images, sound, video, etc in WPF.
What is the use of System.Windows.Navigation namespace in WPF?
System.Windows.Navigation namespace contains different classes for navigation between windows.
What is 'One-way-to-Source ' binding property?
In One-way-to-Source binding when the target property changes, the source object gets updated.
Which namespace is used to work with 3D in WPF?
System.Windows.Media.Medi3D
How to define a button USING XAML?
To define a button in WPD using XAML use the following syntax,
<Button Name="btnName">btnCaption</Button>
Example:-
<Button Name="btnClick">Click Me</Button>
Here the <Button> element specifies the use of the Button class.
What is the use of "System.Windows.Markup" namespace in WPF?
The System.Windows.Markup namespace provides some helper classes for XAML code.
Which namespace provide classes for integration with WPF and Win32?
The "System.Windows.Interop" namespace provides classes for integration of WPF with Win32.
What is the use of System.Windows.Media namespace?
It is the root namespace to several other media related namespaces. It provides different types to work with animations, 3D rendering, text rendering and other multimedia services.
What are the core WPF assemblies?
The core WPF assemblies are:
WindowsBase.dll: It defines the core types constituting the infrastructure of WPF API.
PresentationCore.dll: Defines numerous types constituting foundation of WPF GUI layer.
PresentationFoundation.dll: It defines WPF control types, animation & multimedia support, data binding suport and other WPF services.
Besides these three libraries WPF also uses an unmanaged binary called milcore.dll which acts as a bridge between WPF assemblies and DirectX runtime layer.
What is Silverlight XAML?
Silverlight XAML is a subset of WPF XAML meant for Silverlight applications. Silverlight is a cross-platform browser plug-in which helps us to create rich web content with 2-dimensional graphics, animation, and audio and video.
What's the use of System.Windows.Controls.ContentControl?
It holds a single piece of content. This can start from a simple label and go down to a unit level of string in a layout panel using shapes.
System.Windows.Controls.ItemsControl
This is the base class for all controls that show a collection of items, such as the ListBox and TreeView.
What is the class to be used for creating Rectangle, Polygon, Ellipse, Line, and Path?
System.Windows.Shapes.Shape
What are dependency properties?
Using the properties of a class into another class is called as dependency properties
Can I use user controls and third-party controls including ActiveX controls in WPF?
Windows Forms user controls will work the same as the standard Windows Forms controls, which means you can certainly use them in WPF applications. As far as third-party controls go, it depends on how these controls are built. If they are built as managed Windows Forms custom controls they will also work fine in this scenario. If they are built as ActiveX controls they can also be used in a WPF application as long as they are contained within a WindowsFormsHost control. Since Windows Forms already has support for hosting ActiveX controls, all you need to do is generate the managed wrappers for the ActiveX control and then use those wrappers to instantiate the control and host it within the WindowsFormsHost control on a WPF window or page. One handy way to do this is to simply create a Windows Forms user control that contains the ActiveX control and then simply host the user control in the WindowsFormsHost control.
Can I use Windows Forms in a WPF application?
Yes you can. You can have a WPF application pop a Windows Form much in the same way that you can pop a WPF window from a Windows Forms application. Furthermore, you can place Windows Forms controls side-by-side with WPF controls on a WPF window or page by using the WindowsFormsHost control that will ship as part of the interoperability layer.
I can't seem to find System.Windows.Forms.Integration, where do I find it?
The System.Windows.Forms.Integration namespace is defined in WindowsFormsIntegration.dll which currently ships in the WinFX SDK, not in the standard redist. Therefore, the file will be found in "\Program Files\Reference Assemblies\ Microsoft\Avalon\v2.0.50215".

Comments

Post a Comment