lblbgcolor resource is used to set the background property of lable.ĭynamic Resource we use in a situation where we want to change the value of property at run time. SolidColorBrush resource named lblbgcolor defined. Ībove code, Grid control uses the Resources property () to define resource. Let's have a sample program, Add the below code snippet in Window1.xaml file inside the Grid. The value of StaticResource is determined at the time of loading. We should use the StaticResource markup extension to define the resource as a static resource. Question 4: What are static and dynamic resources? keyName: key name of the resource, which is unique string to identify the resource.markupExtension: Define type of resource.propertyName: Name of the property that takes its value from the resource.elementName: Name of the element that uses the resource.However, if you define a resource for the grid element, then the resource applies only to the child elements of the grid element. For example, if you define a resource for a Window element that has a Grid as a child element, then the resources defined for the window elements can also be used by the grid element. Any resource that you define for an element also applies to their child elements of that element. The best way of defining the resources is on a Window or Page element level. For example, you can set the background property on several elements in a WPF application using a single resource. Resources in WPF allow you to set the properties of multiple controls at a time. Īnswer: Windows Presentation Foundation (WPF) resources provide a simple way to reuse commonly defined objects and values. The code sets VerticalContentAlignment and HorizontalContentAlignmentproperties to bottom and right. You want to set the contents of the Button and TextBox to bottom and right. The default vertical and horizontal alignment of content of a TextBox is left and top. If we create a UI with a Button and a TextBox control, the UI looks like the following figure where the default vertical and horizontal alignment of content of a Button is center. These properties are defined in the class that is the parent class of all controls in WPF. These two properties are HorizontalContentAlignment and VerticalContentAlignment. Question 2: What is Content Alignment in WPF?Īnswer: The content of content controls in WPF is dealt using various properties. Can easily draw vector graphics that scale without jagged aliasing.Transforming objects including shapes, controls and video.Can use shared styles which can be used across the same controls to provide the same theme, skin and design.Can provide smooth graphical effects such as drop shadows and color gradients.Can easily load/play audio and video files.In a nutshell the following things can be done using WPF: Apart from dropping controls on " Windows Forms" just as developers have been doing for years, WPF provides an extra rapid boost to the application development including Rich User Interface, Animation and much more. It's a re-invention of a UI for Desktop applications using WPF. Answer: WPF stands for Windows Presentation Foundation.
0 Comments
Leave a Reply. |