100 likes | 184 Views
Resource File and Styling in SL. Mahender Senior Software Engineer United Health Group. Mahender Sarangam.
E N D
Resource File and Styling in SL Mahender Senior Software Engineer United Health Group
Mahender Sarangam • Having 5 years of experience on .NET Technologies. Working as a Senior Software Engineer in United Health Group (UHG India Information Service Ltd.). Worked with Big Firms like Deloitte Consulting & Wipro Technology. • Got Technical Acquaintance on Technologies like C#, ASP.NET,AJAX, LINQ, Silverlight, WPF,WCF ,SQL Server, Team Foundation Server(TFS) and SharePoint Technology. • MCTS Certified in Web Technologies. • Blog : http://Msarangam.wordpress.com
What are Resource File • In Today Applications, resource places a important role in application development. Resource File may be any Images, Language specific RESX file, Audio, video • Reason for Resource Files • Reuse objects • Centralize details • Create non visual objects • In Silverlight, Resources can be managed in the following ways: • Loading on Demand • Resource embedded inside XAP/Assembly • Resources from external assemblies
When we add Resource File to Silver Light Client project, How to deploy the resource file • With the help of Build Action property in Visual Studio , Mode of Deployment is decided • Marking BUILD Action as Resource, Content and None • When Build action is Resource ,Then Image file is embedded within Silverlight dll. Size of dll will be more. • When it is Content, Resource file will be part of XAP • When it is NONE, then we need to manually copy the resource file under ClientBin folder • Need to call resource from other silverlight library , we can refer like “/assemblyName;component/Location”
Resources must be defined within an appropriately named collection called Resources. • This collection is a ResourceDictionary, a specialized dictionary containing resources identified by implicit or explicit keys • A merged resource dictionary enables you to declare the contents of a resource dictionary by referencing an external file, and to use the externally defined resources to augment the resources found in an existing FrameworkElement.Resources property location
Styles are extremely important because they allow developers to control the look and layout of controls across their application. • This is a much faster alternative to updating each and every control in your application individually. • A style resource in Silverlight is a way to create reusable properties for various controls. • Styles in Silverlight are powerful mechanisms that allow controlling the visual representation of elements in a unified way /consistent look for all user interface elements. • Each Silverlight element has a series of attributes that you set to make a style for an element.
Styles as a resource • You can declare it at User Control level where it is accessible to only the element on that User Control. • You can define it at application level and have the style available to the whole application. • You can also define the style in a resource dictionary and have that accessible to the whole application • Application Level Resources: Applies style to Global level i.e. at application Level. • Style customTextBlockStyle = Resources["StyledTextbox"] as Style;
Cascading Styles: • you can build a powerful and reusable set of styles to apply in your Silverlight applications • <Style x:Key="LargerStyledTextbox" TargetType="TextBox" • BasedOn="{StaticResourceBlueStyledTextbox}"> • <Setter Property="FontSize" Value="25"/> • Merged Dictionaries
<UserControl.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="..." /> <ResourceDictionary Source="..." /> <ResourceDictionary Source="..." /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary></UserControl.Resources>