WPF Interview Questions and Answers
Q1. What is supposed with the aid of WPF?
Ans: Windows Presentation Foundation (WPF) is a next-era presentation device for building Windows purchaser packages with visually stunning person reviews. With WPF, you may create a extensive range of both standalone and browser-hosted packages
Q2. What is Data Binding in WPF
Ans: Data Biding in WPF is a way how the information is speaking among the source and target. It is absolutely updating the statistics in view(application UI) with appreciate to statistics in the view model(presentation good judgment) and vice versa.
Q3. What is Converter in WPF ?
Ans: Converter are used in Data Binding. Converters are used when the source and target types are one of a kind, or while the goal ought to have a exclusive value than that of the supply.
Q4.What are Templates present in WPF ?
Ans: WPF allows you to absolutely alternate the visual look of a manage and illustration or Structure of facts. Templates in WPF allow you to fully change the UI of some thing.
There are types of Templates in WPF:
1. Data Template
2. Control Template
Q5.What are Triggers in WPF ?
Ans: A Trigger sets houses or begins actions, such as animation, when a assets price modifications or while an occasion is raised. Triggers are utilized in styles to perform some moves. Triggers create visible effects on controls. By the use of Triggers we can change the advent of Framework Elements.
There are three types of Triggers to be had.
1. Property Trigger
2. Event Trigger
3. Data Trigger
Q6.What is Style in WPF ?
Ans: As the call tells it's miles a way to personalize or customise the appearance or look of objects. A fashion is a set of values which represents residences of a designated manipulate. We can assign sure set of styles collectively for a particular kind of manage ( like all buttons, all textboxes etc) or restriction the fashion for use only by means of those controls which you want explicitly with the help of keys(x:key).
Q7. What is Dependency Property in WPF ?
Ans: WPF introduces a new belongings referred to as Dependency Property or quickly you may like to call it as DP. Dependency Property comes with some stronger functions further to regular CLR Properties.A lot of capabilities come with DP. A Dependency Property is a Property whose price depends at the external assets, such as animations, statistics bindings, patterns, or visual tree inheritance. Not most effective this, but a Dependency Property additionally has changed, facts binding and styling.
One vital factor to keep in thoughts is that Dependency Properties are declared as static. Because Dependency Property is maintained and declared at magnificence degree. All the items of the elegance use the unmarried property declared on elegance level rather than the usage of for my part.
Q8. What is the Data Binding Modes in WPF ?
Ans: It is a assets of Binding class which is about in the course of the binding indicates the route of the facts waft.
Four kind of Modes are there in WPF. They are:
OneWay : Target is up to date when source changes
TwoWay : Target is updated when the supply modifications, and further, the source is updated while the target modifications.
OneWayToSource : Only the supply is up to date whilst the target modifications.
OneTime : Target is up to date simplest the primary time the source adjustments.
Q9. What is XBAP?
Ans: XBAP stands for XAML Browser Application. XBAP lets in for WPF applications for use inside a browser. The .NET framework is required to be installed on the customer gadget. Hosted programs run in a partial trust sandbox environment. They aren't given complete get right of entry to to the laptop's sources and no longer all of WPF functionality is available.
Q10. What is BAML?
Ans: BAML, which stands for Binary Application Markup Language, is actually XAML that has been parsed, tokenized, and transformed into binary shape. Although any chew of XAML can be represented with the aid of procedural code, the XAML-to-BAML compilation system does not generate procedural supply code
Q11. What are viable ways to put in force disbursed packages in .NET?
Ans: There are 2 possible ways to put in force dispensed packages in .NET,
.NET Remoting
ASP.NET Web Services
Q12. What is the distinction between xmlns and xmlns:x in WPF ?
Ans: Bothe namespaces enables to outline / resolved XAML UI factors.
The first namespace is the default namespace and enables to resolve usual WPF elements.
Hide Copy Code
xmlns="http://schemas.Microsoft.Com/winfx/2006/xaml/presentation"
The 2d namespace is prefixed by “x:” and allows to resolve XAML language definition.
Hide Copy Code
xmlns:x="http://schemas.Microsoft.Com/winfx/2006/xaml"
For example for the underneath XAML snippet , we've two things one is the “StackPanel” and the alternative is “x:call”. “StackPanel” is resolved through the default namespace and the “x:call” is resolved by way of the usage of “xmlns:x” namespace.
Hide Copy Code
<StackPanel x:Name="myStack" />
Q13. What is XAML in WPF and why can we need it?
Ans: XAML is a XML document which represents your WPF UI. The whole factor of creating the UI representation in XML become write as soon as and run it anywhere. So the identical XAML UI may be rendered as home windows utility with WPF and the identical UI can be displayed on the browser using WPF browser or Silverlight software.
Q14. How can I create Custom Read-Only Dependecy Properties?
Ans: The common motive for specifying a study-best dependency assets is that these are the homes that is used to decide the country, however in which the nation is described in a multitude of factors. A regular instance for a study-only belongings is IsMouseHover
This instance indicates the way to 'check in' an connected assets as study-best. You can use dependency residences on any 'DependencyObject' sorts.
[C#]
public static readonly DependencyProperty IsBubbleSourceProperty = DependencyProperty.RegisterReadOnly(
"IsBubbleSource",
typeof(Boolean),
typeof(AquariumObject),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender)
);
Q15. How can I enumerate all the descendants of a visual item?
Ans: You can enumerate all of the descendants of a visual item as follows :
[C#]
// Enumerate all the descendants of the visual item.
Static public void EnumVisual(Visual myVisual)
for (int i = zero; i < VisualTreeHelper.GetChildrenCount(myVisual); i++)
// Retrieve baby visual at special index value.
Visual childVisual = (Visual)VisualTreeHelper.GetChild(myVisual, i);
// Do processing of the child visual object.
// Enumerate youngsters of the child visible object.
EnumVisual(childVisual);

