Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Architecture of WPF

Answer»

Below figure shows the full ARCHITECTURE of WPF which has three major SECTIONS:-
(1)Presentation core
(2)Presentation framework
(3)Milcore.
In the below diagram we can see how other sections like DirectX and Operating System interact with the system. Below is the detail of allthing which comes in below image.



WPF Architecture

(1)User32-: It decides what goes where on the screen.
(2)DirectX:- As we know WPF uses DirectX internally. DirectX TALKS with drivers and renders the content.
(3)Milcore:- Mil stands for media integration library. This section is unmanaged code because it acts like a bridge between the WPF managed and the DirectX / User32 unmanaged API.
(4)Presentation core:- It is a low level API exposed by WPF providing features for 2D, 3D, GEOMETRY, etc.
(5)Presentation framework:- This section has high level features like application controls, layouts, content, etc., which helps you build up your application.

2.

How can we set ControlTemplate in WPF

Answer»

Below is the simplest CODE to set controltemplate in wpf without too much effort-


BUTTON bt = NEW Button();
StringBuilder sb = new StringBuilder("");
sb.Append( "sb.Append("xmlns:data='clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data' xmlns:mc='http://schemas.openxmlformats.org/markup-compatibility/2006' ");
sb.Append("TargetType='Button' >");
sb.Append("");
sb.Append("
");
ControlTemplate CT = XamlReader.Load(sb.ToString()) as ControlTemplate;
bt.Template = ct;
bt.Content = "asdfd";
ContentStackPanel.Children.Add(bt);

3.

Wha is BAML in WPF

Answer»

BAML(Binary APPLICATION Markup Language) is SIMPLY XAML which 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 we can say that BAML is not like Microsoft intermediate language and 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 awaare of its existence.

4.

Name different pre-defined document formats in WPF

Answer»

Name DIFFERENT pre-defined document FORMATS in WPF
Below are the list of pre-defined document formats in WPF
(1)Bitmap
(2)CSV file
(3)HTML
(4)RTF
(5)STRING
(6)Text
(7)Audio

5.

What do you think WPF replace DirectX

Answer»

No we cannot say that WPF 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.

6.

WPF new features

Answer»

As all of US know WPF is a next generation UI framework to build RICH user application. And it is part of .NET framework 3.0 and higher version.WPF combines application UIs, 2D graphics, 3D graphics, documents and MULTIMEDIA into one single framework. Its vector based rendering engine uses hardware acceleration of modern GRAPHIC cards. This makes the UI faster, scalable and resolution independent.Below figure will help you to understand wpf features-

wpf

7.

Operating systems support by WPF

Answer»

Below are the operating SYSTEMS that support WPF:-
(1)Windows7
(2)Windows Vista
(3)Windows XP Service PACK 2 or LATER

8.

working with hardware acceleration in wpf

Answer»

As all of us hardware ACCELERATION is the process where we use hardware to perform some functions rather than performing those functions USING the software which is running in the CPU. WPF exploits hardware acceleration in a two tier MANNER. Below figure will CLEAR all the doubt:-

WPF

Tier 0:- If the video card does not support hardware acceleration then WPF uses Tier 0 rendering mode. In other words it uses software acceleration. This corresponds to working of DirectX version less than 7.0.

Tier 1:- If the video card supports partial hardware acceleration then WPF uses Tier 1 rendering mode. This corresponds to working of DirectX version between 7.0 and 9.0.

Tier 2:- If the video card supports hardware acceleration then WPF uses Tier 2 rendering mode. This corresponds to working of DirectX version equal or greater than 9.0.

9.

Can we set Textbox multiple lines for TextBox

Answer»

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.

10.

Different WPF controls by there Function

Answer»

(1)Buttons:-Button and RepeatButton.
(2)Data Display:- DataGrid, LISTVIEW,and TreeView.
(3)Date Display and Selection:- Calendar and DatePicker.
(4)Dialog Boxes:- OpenFileDialog, PrintDialog, and SaveFileDialog.
(5)Digital Ink:- InkCanvas and InkPresenter.
(6)Documents:- DocumentViewer, FlowDocumentPageViewer, FlowDocumentReader, FlowDocumentScrollViewer, and StickyNoteControl.
(7)Input:- TextBox, RichTextBox, and PasswordBox.
(8)Layout:- Border, BulletDecorator, Canvas, DockPanel, Expander, Grid, GridView, GridSplitter, GroupBox, PANEL, ResizeGrip, Separator, ScrollBar, ScrollViewer, StackPanel, Thumb, Viewbox, VirtualizingStackPanel, WINDOW, and WrapPanel.
(9)Media:- Image, MediaElement, and SoundPlayerAction.
(10)Menus:- ContextMenu, MENU, and ToolBar.
(11)Navigation:- Frame, Hyperlink, Page, NavigationWindow, and TabControl.
(12)Selection:- CheckBox, ComboBox, ListBox, RadioButton, and Slider.
(13)User Information:- AccessText, Label, Popup, ProgressBar, StatusBar, TextBlock, and ToolTip.

11.

Does XAML file compiled or Parsed

Answer»

By DEFAULT XAML files are COMPILED and we also have options to LET it be PARSED.

12.

Types of windows in WPF

Answer»

Below are the THREE TYPES of windows in WPF-
1)NORMAL Window
2)Navigate Window
3)Page Window

13.

Code to Find Child of Control in WPF

Answer»

Code to Find Child of Control in WPF
Below is the code to find the all child control in parents by using For LOOP
/// Method to get child control of specified type
/// typeparam name="Ty" Type of child control queried
/// param name="parent" Reference of parent control in which child control resides
/// Returns reference of child control of specified type (T) if found, OTHERWISE it will return null

private static T FindVisualChild< Ty>(DependencyObject parent) where Ty : DependencyObject
{
for (int x = 0; x < VisualTreeHelper.GetChildrenCount(parent); x++)
{
DependencyObject child = VisualTreeHelper.GetChild(parent, x);
if (child != null && child is Ty)
return (Ty)child;
else
{
Ty childOfChild = FindVisualChild< Ty>(child);
if (childOfChild != null)
return childOfChild;
}
&nbsp}
return null;
}

14.

Can we say WPF is alternate of DirectX?

Answer»

Can we SAY WPF is alternate of DirectX?
ANSWER is simply no as WPF can NEVER replace DirectX. Because we cannot use WPF to CREATE games with stunning GRAPHICS. WPF is simply means to be a replacement for windows form, not DirectX.

15.

What is a Routed event in WPF

Answer»

When we talk about a TYPICAL WPF APPLICATION which 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.

16.

What is BAML

Answer»

BAML 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.

17.

Use of relay command in WPF?

Answer» USE of relay COMMAND in WPF?
In WPF relay command is mainly used to bind and INTEGRATE commands directly to the PROPERTIES of ViewModel.
18.

What are Freezable objects in WPF and states?

Answer»

What are FREEZABLE objects in WPF and states?
Freeable objects in WPF are distinct KIND of object which posses two states.
(1)Frozen
(2)Unfrozen.
These objects can be used for the improvement of the PERFORMANCE LEVEL of the APPLICATIONS.

19.

Name the different triggers in WPF?

Answer»

Name the different triggers in WPF?
Triggers are basicly USED to do an action and to CHANGE the property value of the application.
There are five triggers in WPF-
(1)Property Trigger
(2)MULTI Trigger
(3)Event Trigger
(4)MultiData Trigger
(5)Data Trigger

20.

Can we create WPF application without XAML and what is the use of XAML

Answer»

Can we create WPF application WITHOUT XAML and what is the use of XAML
Yes, we can do this on both way with XAML and without XAML with the help of CODE. Now question come why we use XAML and its benefits in XAML we can create and initialie objects. Below are the benefits of XAML in WPF.
(1)XAML code is short and easy to read
(2)This will separate the designer code and LOGIC
(3)This separation of XAML from Userinterface logic helps designer and developer both to clearly do there work
(4)Graphical design tools like Expression Blend require XAML as source.

21.

How to access XAML objects in behind code

Answer»

To get access to XAML objects in behind code we NEED to DEFINE with same name as GIVEN in XAML document. For instance in the below code snippet we named the OBJECT as objtext and the object is defined with the same name in the behind code.

XAML Objects

22.

How can I sort items in a ListBox in WPF

Answer» SORTING can be done VIA a mechanism on the ItemsCollection object, so it applies equally to all ItemsControls. ItemsCollection has a SortDescriptions property that can hold any number of System.ComponentModel.SortDescription instances. Each SortDescription describes which property of the items should be used for sorting and whether the sort is ascending or DESCENDING. For example, the following code SORTS a bunch of ContentControl items BASED on their Content property:
// Clear any existing sorting first
myItemsControl.Items.SortDescriptions.Clear();
// Sort by the Content property
myItemsControl.Items.SortDescriptions.Add(
new SortDescription( Content , ListSortDirection.Ascending));
23.

Features and why to use WPF

Answer»

Below are the some features of WPF:-
(1)It Uses DirectX Engine for rendering GUI
(2)It do not USE GDI 32 programming at all as opposed to Win32 applications
(3)It do not require more time or cost for graphics, drawing or animation programming
(4)It is Easy to change resolution UNLIKE win32 application
(5)It is XAML Friendly.
(6)It has .NET API that has integrated to XAML (Xtensible Application Markup Language)
(7)Easily select the Controls unlike Win32 Controls.
(8)It has the ability to create 3D graphics in windows apps
(9)It contains Separate API for graphics and animation
(10)Most powerful Windows UI Framework

Below are the some important uses of WPF:-
(1)For the better User Interface & the DESIGN
(2)Customization of Controls
(3)Integrating Flash, Direct, Win32, Windows Forms
(4)For Generic consistency professional look (Using Styles like CSS in Web)

24.

What is PRISM its advantage and components

Answer»

Prism is a Framework for DEVELOPING Composite or Complex applications specific to WPF or Silverlight or Windows Phone.It uses modularity; It allows to break application into pieces can be called as Modules.It uses design patterns like MVVM, Command Patterns, Dependency Injection (DI), and Inversion of Control (IC), Separation of Concerns to achieve loosely coupling.

Advantages of PRISM:-
(1)Reusability: It allows building component in one framework (WPF) and reusing it in other PLATFORMS (Silverlight).
(2)Extensibility: Due to its design patterns nature new functionality that is to be added is easily extensible for future purpose.
(3)Flexibility: PRISM is flexible to develop large complex applications
(4)Team Collaboration: Simultaneous module development is possible and Multiple TEAMS can work on different modules simultaneously.
(5)Fault Tolerance : It allows components to be thoroughly and completely tested thus results in error free application development of better quality.
(6)Maintainability: The large scale complex applications developed using PRISM are maintenance friendly
(7)Modularity: As everything is break down into modules, prism supports modularity due to this PRISM is flexible, extensible.

Components of PRISM:-
(1)Shell : Template that Defines structure of the UI. Shell contains SEVERAL regions.
(2)Regions: Regions are used to specify specific portion of shell as elements to inject view at runtime
(3)Modules: These are major functional areas of the application. Each module need to be independent of other,
(4)Views: Modules contains number of views. Views in Prism are built using MVVM design pattern.
(5)Boot-Strapper: This component is Responsible for Creating Shell and initializing application.

25.

What are the dependency properties

Answer»

These dependency properties belong to one class but can be used in another . And the CODE is as below :-

< 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.

26.

Methods in DependencyObject in WPF

Answer»

Below are the 3 methods in DEPENDENCYOBJECT in WPF:-
(1)ClearValue
(2)SetValue
(3)SetValue

27.

Types of controls in WPF

Answer»

Below are the 3 controls in WPF:-
(1)Content CONTROL
(2)ITEM Control
(3)Layout Control

28.

How to apply tooltip over a disabled element

Answer»

We have to use the ShowOnDisabled attached PROPERTY of the ToolTipService CLASS From
XAML and this would LOOK LIKE the following on a Button:- < Button ToolTipService.ShowOnDisabled= True > Button>

29.

Routed events in WPF

Answer»

When we talk about Routed event in WPF .We take an example of typical WPF APPLICATION, which 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.

30.

Use of System.Windows.Media.Visual dll

Answer»

Visual class is a drawing object which abstracts drawing instructions, how drawing should be drawn like CLIPPING, opacity and other functionalities. Visual class also acts like a bridge between UNMANAGED MilCore.dll and WPF MANAGED classes. When any class derived from visual it can be displayed on windows. If you want to CREATE your own customized user interface then you can program USING visual objects.

wpf dll

31.

can we unable spell checking in WPF TextBox

Answer»

Yes we can UNABLE spell check in textbox by just
enable SPELLCHECK and below is code for that
< TextBox SpellCheck.IsEnabled="TRUE" LANGUAGE="en-US" />

32.

Name the different layout panel of WPF

Answer»

These are the five most LAYOUT panels of WPF:-
(1)Grid Panel
(2)Stack Panel
(3)Dock Panel
(4)Wrap Panel
(5)Canvas Panel

33.

Namespace needed to host wpf control on window application

Answer»

Below are the FIVE namespaces NEEDED to host WPF control in WINDOW application
a)PresentationCore.dll
b)PresentationFramework.dll
c)UIAutomationProvider.dll
d)UIAutomationTypes.dll
e)WindowsBase.dll

34.

What are the major subsystem of WPF

Answer»

Below are the MAJOR subsytem of WPF
1) Object
2) Threading.DispatcherObject
3) Windows.DependancyObject
4) Windows.Media.Visuals
5) Windows.UIElements
6) Windows.FrameworkElement
7) Windows.Controls.Control

35.

difference between custom and user control in WPF

Answer»

Below is the difference between custom and user control in wpf both are USED in wpf and asp.net both way
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.