Which of the following is an event in WPF ?
NOTE: This is objective type question, Please click question title for correct answer.
What are XBAP'S?
XBAP
Xml Browser Applications:
They are basically WPF applications which run with .xbap extension in the
browser.Their main features are:
1)They provide a page based navigation model .Root tag is Page.
In page based navigation, we can navigate from one .Xaml file to another
by using the standard techniques like HyperLinks, NavigationService,
and we are provided with back and forward buttons in the toolbar
that appears in the output to visit the pages that have been opened using
HyperlInk, NavigationService.
2)They have restrictive permissions:
example: we cannot do database connectivity, file handling or alter registries
using XBAP's
3)We can do animations, drawings, transforms apply brushes on XBPAP files.
Is it possible for a control to define a handler for an event, that the control can't itself raise?
Yes, It's is possible for a control to define a handler for an event, that the control can't itself raise.
These incidents are called attached events.
For example, a button controls in a grid. The button class defines a click event, but the grid class doest not. However, you can still define a handler for buttons in the grid by attaching the Click events of the button control.
What is the difference between User Settings and Application Settings in WPF?
The User Settings are Read/Write, they can be read or write even at runtime and can be saved.
The Application Settings are read-only, they can only be written at design time.
which dll is also called as the engine of managed graphics?
NOTE: This is objective type question, Please click question title for correct answer.
What is Style Inheritance?
It is the technique through which one style aquires the features of another style
It is implemented through BasedOn property of the Style class.
example:
<Window x:Class="WpfApplication14jan.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Window.Resources> <Style x:Key="One" TargetType="{x:Type Button}"> <Setter Property="Foreground" Value="Green"/> </Style> <!-- This is how the style inheritance is implemented--> <Style x:Key="Two" BasedOn="{StaticResource One}" TargetType="{x:Type Button}"> <Setter Property="Background" Value="Yellow"/> </Style> </Window.Resources> <Button Height="100" Width="100" Style="{StaticResource Two}" Content="Welcome"> </Button> </Window>
//Note:
//When you run the WPF Form, the Button will aquire the Formatting from both the
//styles
Difference between x:Key and x:Name
x:Key and x:Name
These are both the XAML attributes that are specified in the declaration of XAML elements.
x:Key:
It is used mainly with the WPF Stylesheets or in ResourceDictionaries.
x is the namespace prefix
Key is the element specified by the x namespace prefix
x:Key is not applicable for user interface elements like the Button
example:
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<Style x:Key="One" TargetType="{x:Type Button}">
<Setter Property="Foreground" Value="Green"/>
</Style>
</Window.Resources>
<!--how key is applied-->
<Button Height="100" Width="100" Style="{StaticResource One}" Content="good"/>
</Window>
USES:
using the Key element, we can refer the StyleSheet defined in <Style></Style> tag in some other
<Style></Style> tag or in the declaration of some user interface element.
In the above example, I have mentioned how Key is used to define the Style of a Button.
x:Name:
It is used to mention the names of StyleSheets as well as the user interface controls
example:
<Button Height="100" Width="100" x:Name="mybutton" Content="good"/>
x:Name can also be accessed in the code-behind (.xaml.cs /.xaml.vb), but x:Key cannot be accessed in code behind
How is mapping done between CLR namespaces and XAML namespaces?
Consider this XAML declaration
<Window x:Class="WpfApplication14jan.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> </Window>
The attribute xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" is
responsible for the mapping. Without this, no XAML user interface can be created
or code executed.
How many predefined classes are there in the WPF Command Library?
NOTE: This is objective type question, Please click question title for correct answer.
Difference between MediaPlayer and MediaElement ?
MediaPlayer has no visual interface and not suitable to display videos.
It cannot be placed on the XAML designer.
It provides Media PlayBack for drawings.
We have to use VideoDrawing or DrawingContext classes for that.
example:
MediaPlayer player = new MediaPlayer();
player.Open(new Uri("c:\\intro.wmv", UriKind.Relative));
VideoDrawing aVideoDrawing = new VideoDrawing();
aVideoDrawing.Rect = new Rect(0, 0, 100, 100);
aVideoDrawing.Player = player;
player.Play();
MediaElement has got visual interface and
can easily display videos using its built in properties.
It is designed for XAML use and can be placed on the XAML
designer.
What is x:Code?
x:Code is a directive element defined in XAML.
An x:Code directive element can contain inline programming code.
The code that is defined inline can interact with the XAML on the same page.
example:
<Window x:Class="WpfApplication14jan.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300" Loaded="Window_Loaded"> <Grid Name="dd"> <Button Name="button1" Click="Clicked">In Line code!</Button> <x:Code> <![CDATA[ void Clicked(object sender, RoutedEventArgs e) { button1.Content = "WPF Inline Code"; } ]]> </x:Code> </Grid> </Window>
How many type of templates are available in WPF..?
Data Templates: Data Template visual representation of data in control with style. like List box.
Control Templates: Control Template suppliers a visual representation of a UI Control like Button or List View.
Items Panel Templates:Item Panel Templates uses when we want to show data in Hierarchical way like child object use under parent object.
What is the WPF Unit?
The WPF Unit is measured in DPI.
First we need to understand about DPI and PX (i.e. Device Independent Pixels & Physical Pixels)
1 DPI = 1/96 inch
1 PX = 1/DPI - Depends on screen type
The default system setting is 96 DPI
Note: If the DPI increases, the number of physical pixels which compose one device independent pixel also increases. Hence, objects that have their sizes specified in device independent pixels get larger as the system DPI increases
What are the core WPF Assemblies that one should refer in a WPF application?
1) PresentationCore.dll: Visual rendering of low-level types UIElement.
2) PresentationFramework.dll: Most of the common controls, and also support for data binding.
3) WindowsBase.dll: Lower-level types like DependencyObject and DependencyProperty.
What is the Class Hierarchy in Windows Presentation Foundation?
* System.Threading.DispatcherObject class represents on object associated with a "Dispatcher".
* System.Windows.DependencyObject class is the base class for classes that support dependency properties.
* System.Windows.Media.Visual class is the base class for objects that can be rendered to a WPF window or page.
* System.Windows.UIElement class defines core subsystems like Layout, Input, Focus and Events(LIFE).
* System.Windows.FrameworkElement introduces data binding and data templates, styles and animation.
* System.Windows.Controls.Control class adds a feature called templating. This is the base class for all the controls that the user interacts with.
* System.Windows.Controls.ContentControl can hold a single nested element.
What are the different Data Binding Modes in Windows Presentation Foundation?
The different Data Binding Modes are:
1) OneWay: The target is updated when the source changes.
2) TwoWay: The target is updated when the source changes, and similarly, the source is updated when the target changes.
3) OneWayToSource: Only the source is updated when the target changes.
4) OneTime: The target is updated only the first time the source changes.
What is the importance of INotifyPropertyChanged in WPF?
* This interface contains a single event called "PropertyChanged" of the delegate type "PropertyChangedEventHandler".
* To notify the WPF/Silverlight framework whenever the value of a property changes in an object, fire the event in the "set" accessor of the property.
What is the importance of INotifyCollectionChanged in WPF
* This interface is similar to INotifyPropertyChanged, which is to be implemented to notify the WPF/Silverlight framework whenever any changes occur in a collection, like adding an object or deleting an object.
* "ObservableCollection" is a built-in class which implements the INotifyCollectionChanged interface.
What is Logical Tree in WPF?
* Logical tree describes the relations between elements of the user interface.
* Every aspect of WPF (properties, events, resources, and so on) has behavior tied to the logical tree.
* Logical tree is responsible for:
1) Inherit Dependency Property values
2) Resolving Dynamic Resources references
3) Looking up element names for bindings
4) Forwarding Routed Events
* System.Windows.LogicalTreeHelper class is used to traverse the logical tree.
What is Visual Tree in WPF?
* Visual tree is an expansion of a logical tree, in which nodes are broken down into their visual components.
* Visual tree contails all logical elements including all visual elements.
* The elements that appear in a visual tree derive from 'System.Windows.Media.Visual' and 'System.Windows.Media.Visual3D'.
* Visual tree is responsible for:
1) Rendering visual elements
2) Propagate element opacity
3) Propagate layout and render transforms
4) Propagate the 'IsEnabled' property
5) Do hit-testing
NOTE:
* Visual tree is dependent on Windows theme.
* Visual tree is empty until the window undergoes layout at least once. So it must be navigated in 'OnContentRendered' event handler.
* System.Windows.VisualTreeHelper class is used to traverse the logical tree.
No comments:
Post a Comment