How to implement the style in Silverlight? Silverlight is a web-based application framework to write rich internet application. The style is a collection of property values that applies to an element. The style allows the application to look more visually appealing. The style is defined in the file named App.xaml. The silverlight style will be given as: <Application.Resource> <Style a:key="app_button" TargetType="Button"> <Setter Property="FontFamily" Value="Verdana" /> <Setter Property="FontSize" Value="36" /> </Style> </Application.Resource> This is the programming code that is used to apply the style to a particular Button. <Button Style="{StaticResource app_button}" Content="app_button" ></Button>
|
What are the different development tools used in Silverlight? The tool that is used with the Silverlight application is the Microsoft Visual Studio. The applications are written in .NET language. So, all the associated tools with the .NET language will also work with the Silverlight as well. Microsoft Expression Blend is the tool that is used to develop and design the Silverlight user interface applications. Visual studio is the platform that is used to debug the Silverlight errors and use error free applications. Silverlight usually come in the zip format and it contains the .XAP format that consists of one or more .NET managed assemblies that are stored in .DLL files. It also consists of AppManifest.XAML that contains the entry point including the important classes and assemblies.
|
What are the different important files that are used in Silverlight? There are several files that are required to be used in silverlight to make it function properly and to include the properties of applications together: AppManifest.XAML : it consist the list of all the entry points including the class and assembly. This file can be taken and hosted in any HTML file using an object tag. The code will be given as: <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"><param name="source" value="MySilverLightControl.xap"/></object> Silverlight.js and CreateSilverlight.js: contains the initialization of the Silverlight plug-in that will be used in HTML pages.
|
Write the code to populate the controls in Silverlight To populate the control in silverlight the requirement is to create the template and their styles. The code mentioned below does it: The file that is involved in setting up the control is Page.xaml.cs file and then check for the page constructor is being done. The modification will be done in this file as: public Page() { InitializeComponent(); // Write the code for list of items IEnumerable list = GetItems(); // Write the code for Adding of items _listBox.ItemsSource = list; _cmb.ItemsSource = list; // Set the properties of the font from here FontFamily[] ff = new FontFamily[] { new FontFamily("Default font"), new FontFamily("Arial"), }; _cmb1.ItemsSource = ff; } This allows the setting up the list and combo box to set up the properties of the silverlight functions by using the ItemsSource property.
|
What are the steps required to set the controls in silverlight? The steps that are involved in setting up the control in silverlight are as follows: - First the file Page.xaml.cs will be modified to set the property of a particular page and the style of the page. - The GetItems() function will be used in the Page class to get the items from the database and it will be written as follows: List<DataItem> GetItems() { List<DataItem> members = new List<DataItem>(); foreach (MemberInfo mi in this.GetType().GetMembers()) { members.Add(new DataItem(mi)); } return members; } The definition will be added in the DataItem class in the Page.xaml.cs file.
|
What is the purpose of control templates in Silverlight? Control templates allow the control of the data templates to allow easy specification in conversion of the data objects into the user interface element objects. This helps the same content to be displayed to the user. The control templates can be used to modify the visual structure of the template with an existing user interface element. The objects will be controlled by using the property of reusability. The control templates have their own visual appearance defined by native XAML resource. This file is contained in assembly of the silverlight that defines that particular control that is getting used.
|
What are the different resource properties specifying a style? The control properties that are used to define the resources of the styles include the template properties that are internal. The style element is used to control the template properties that can be visualized in a tree format. The code that is being given is as follows: <Style TargetType="Button"> <Setter Property="IsEnabled" Value="true" /> <Setter Property="IsTabStop" Value="true" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <!-- Focus indicator --> <Rectangle x:Name="FocusVisualElement" StrokeDashCap="Round" ...=""/> <!-- Button content --> <ContentPresenter x:Name="Normal" Background="{TemplateBinding Background}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"...=""/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>
|
What are the modes that are provided in Silverlight? Silverlight provides the mode graphics that includes multimedia graphics, animations and interactivity programs at runtime. It is well handled with XAML file and the JavaScript is used to give it overall functionality for user interaction. XAML is used for providing the vector graphics and animations to an application. Textual content can be created using Silverlight as it allows easy to search and index the created graphics that can’t be represented as graphics but text. Silverlight supports the provision to create gadgets and playback of multimedia files or content that is supported by all the browsers. It uses the commercial and non-commercial mode to support both the levels of consumers. It allows the dynamic code that load XML component that can be modified through DOM interface.
|
Explain the element tree in Silverlight architecture. Silverlight architecture functions on the properties given below: Element Tree: is the heart of silverlight application that keeps the object in the tree form like path, image or media element objects. It is a simple container object that stores the data structure in hierarchical methods. It is used to compose and build an application with different properties. It is rich in graphical elements and works just like the DOM (Document Object Model). The XAML parsers are used to build this kind of element tree and it can be provided with CreateFromXAML method used in Silverlight. The element tree wrapper is used to add the code of XML file. The code that is being written to generate the element tree is as follows: class xml.etree.ElementTree.Element(tag, attrib={}, **extra)
|
How to use XAML namescope in Silverlight? Namescope allows the templates in Silverlight to allow the reusability of the content and it can also include the elements with the names defined at the template level. The template can be reused for more than once in the same page. To be able to do that every single template defines their own XAML namescope that differentiate and make it independent from other templates and styles. Due to the difference in the namescope finding the elements within the template from a page is easy. GetTemplateChild method is used to get the template element from the template used in various pages or in a single page. The following code is used to set the same template on two different controls: <UserControlxmlns="http://xyz.com/xaml/presentation"xmlns:x="http://xyz.com/xaml"> <UserControl.Resources> <ControlTemplate x:Key="Temp"> //write your own code here <TextBlock x:Name="TextBlock"/> </ControlTemplate> </UserControl.Resources> </UserControl>
|
How to use XAML namescope at run time? XAML namescope allow the user to create different template files and reference the objects that are declared in XAML. This allows the separate files to be maintained and make it individually separate from each other. XAML uses the parser that creates a set of objects that retain some or all of the relationships that are declared in XAML files. The relationship manages the specific object properties of the created objects. The namescope is used at run time to identify the individual elements from one another and to give the direct reference to an object instance. The instance becomes enabled by using the markups that is used for compilation process. The initializeComponent method is used to initialize the partial class template. Silverlight consists of build in functions and actions that can identify the namescope for different element at run time. The FindName method can be also used at run time to return the reference of the object that is defined by the XAML markup.
|
What is the function of an object tree used in Silverlight? Object tree is used to create and manage the objects in a hierarchical way. This allows easy to make the relation at run time that are related to each other. The relationships are based on the properties of the objects that are similar to one another and the value of the property that are comparatively similar to each other. The object tree consists of branches that are used to store some properties that are collection of other properties and it holds more objects in a chain. The object tree consists of the root element that is considered as parent and it is necessary to maintain the architecture. This architecture is used to reference single object to display the content of it. Object tree structure is composed of parent and child implementation details.
|
What is the procedure to add an event handler in managed code? CLR language specific syntax is used to add event handler as XAML is not the only way to add it. XAML allows the event handler to be added to an object. CLR allows the objects to be included even if it is not being used by any program or application. The event handlers to the object can be added during the run time of the object or the lifetime. The callback method also can be used to add an event using the OnApplyTemplate method. By doing this the event handler will be added to the relevant object that will be ready for the use to the events of the user at run time. The code that will be used to load the event handler in the managed code is given below: <Grid x:Name="LayoutRoot" Loaded="LayoutRoot_Loaded"> <StackPanel> <TextBlock Name="text">Text is given as when on mouse hover</TextBlock> //Write your own code </StackPanel> </Grid>
|
How the even routing method works in Silverlight? Event routing is an important concept that is based on the visual tree. Routing of the events support RoutingStragegy of Bubble, Tunnel and Direct methods that are used to make it possible.
- Bubble: is the most used routing method used. It allows a bubble to propagate the visual tree from source element till it is handled differently to reach the root element. It also allows the event of an object to be handled by the element hierarchy coming from the source element.
- Tunnel: they start at the root element and then traverse down the element in the tree till they have handled and reached the source element of the event. They have their own names that are prefixed with Preview like PreviewMouseDown. Direct: are the normal events that handles the event delegates hooked up to an event.
|
What are the different event modes in Silverlight? There are two different modes in Silverlight: Input events: are the browser dependent that hosts the silverlight plug-in. It handles the initial input that is used for the input events. Silverlight has a plug-in architecture that solves the purpose of responding to the event that is being given from the silverlight object model. Another mode is Non-input event mode: that reports a state change to a particular object in the form of download state or some actions that shows the progress done in web client. There are some frameworks that provides the lifetime information of an object at a framework level. It allows an even to be loaded at a particular instance to show the progress initiated by the web client.
|
What is the difference between logical and Visual tree? Visual tree is the representation of the object tree that is being filtered and modified. Visual tree also reports the objects that are part of the control in a composite form. Visual tree is used for rendering process that includes control template and analysis of control’s structure. Silverlight comes with VisualTreeHelper API that represents the tree in a generalized way. It shows object parent and child relationship properties. The files that are used are as follows: - System.Windows.Controls.ListBox - System.Windows.Controls.Border - System.Windows.Controls.ScrollViewer - System.Windows.Controls.Grid - System.Windows.Shapes.Rectangle
Logical trees add content to the elements using different properties that is being provided with other controls and item properties. Logical tree shows the content model and iterate over the child elements and the content models can be made extensive for the use only. It provides a framework for notifications till all the contents models are not loaded.
Example: ListBox and the files that are used are: - System.Windows.Controls.ListBox - System.Windows.Controls.ListBoxItem - System.String
|
What are the different classes used in Visual tree? The different classes that are used in Visual tree are as follows: - ScrollViewer: allows to include an area that is scrollable and contains the visible elements of it like scroll bar. - ScrollContentPresenter: allows the content of the ScrollViewer to be displayed. - ItemsPresenter: allows the control of the specific item to be used in a visual tree where it present the items that has to be arranged in a panel using ItemsPanel and ItemsControl. - VirtualizingStackPanel: this arranges the stack panel and virtualizes the content used in it in a single line that can be made oriented in any direction either horizontal or vertical. - ContentPresenter: allows the user to present and displays the content of a ContentControl method. It also allows the flow of the content to be managed together in one way and can be represented together.
|
How does the rendering engine work in Silverlight? Silverlight allows many functionalities and provide a rendering engine that optimizes the content of the element tree. It also gives the desired rate of conversation to indicate the optimization technique used in the plug-in. The rendering process involves incremental approach to redraw the frames to reduce the number of pixels in the image and of the content that is changing. It also include non-rasterizing the content that is uncomplete. Silverlight uses vector graphics as data format that can be easily scaled and the size and display can be changed accordingly. The user interface provides lots of tools like Button, etc. that helps in creating user interface element and help in developing a process in which rendering of the objects takes less time. There is a process of rendering that takes place from the root that is top-most node and then progresses to its child from left to right.
|
What does rendering engine in the Silverlight includes? Rendering engine is a powerful engine to render the visual appearance and the content of the page. It also helps in controlling the content of the page. It includes the following:
- Text rendering support: it helps in rendering the text that can be used by the content and to make the visual appearance more effective. - Subpixel positioning: it helps in positioning the pixels and the pixels that are contained by the previous one together. It helps in maintaining a format between the pixels that provide the correct aligning of it. - Custom anti-aliasing for sharper text: Anti aliasing allows the text to be more smooth and to soften the edges of the text. It helps in making the text more legible by aligning text that remains on the pixel positions and rendered in small font sizes. Custom anti-aliasing helps in choosing the better option of it. - Transforms: the transform can be of many type but the main type is path transform or brush transform that is used to transform the text and graphics by resampling the content and the data involved in it.
|
What is the difference between Glyph cache and Image cache? Image cache caches the content associated with the image that is downloaded from a specified URL. If the references will be made to the image multiple times then the image will be loaded from the cache and the time of loading will be less. The pattern or the process will be much more faster. Whereas Glyph cache is used for text based engine to produce rendered text files by rendering the fonts and its properties. Glyph optimizes the readability and increase the resolution of the text that has to be changed. It also applies to the dynamic change of the text and apply the visual properties dynamically.
|