We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback
Platform : WPF
|
Category : Styles and Templates

What are the limitations of Inline Styles and Templates ?

In Extensible Application Markup Language (XAML), style and template properties can technically be set in any one of two ways provided. You can use ’attribute syntax’ to reference a style that was defined within a resource, for example <object Style="{StaticResource myResourceKey}" .../>. Or you can use ’property element syntax’ to define an inline style for an instance.

The attribute usage is much more common. A style that is defined inline and not defined in resources is necessarily scoped to the containing element only and cannot be re-used easily because it has no resource key. In general a resource-defined style is more versatile and useful in keeping with the general Windows Presentation Foundation (WPF) programming model principle of separating program logic in code from design in markup.

Usually there is no reason to set a style or template inline even if you intend to use that style or template in that location only. Most elements that can take a style or template also support a ’content property’ and a ’content model’. If you only use the logical tree you create through styling or templating once, it would be even easier to just fill that content property with the equivalent child elements in direct markup. This would bypass the style and template mechanisms altogether.

Other syntaxes enabled by markup extensions that return an object are also possible with styles and templates. Two such extensions that have possible scenarios include ’TemplateBinding’ and ’Binding’.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon