{"id":785,"date":"2019-02-14T12:34:41","date_gmt":"2019-02-14T12:34:41","guid":{"rendered":"https:\/\/ibex.tech\/windows-iot\/?p=785"},"modified":"2019-02-14T12:34:41","modified_gmt":"2019-02-14T12:34:41","slug":"styles-general","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/uwp-programming-in-c\/styling\/styles-general","title":{"rendered":".Styles General"},"content":{"rendered":"\n<p>You can define a style inline in the XAML for a control, or as a reusable resource. <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Defining styles as a reusable resource<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">Style definition locations<\/h5>\n\n\n<p style=\"padding-left: 30px\">An individual page&#8217;s XAML file (will override a same named resource in App.xaml)<\/p>\n<p style=\"padding-left: 60px\">Will override a same named resource in App.xaml if present.<\/p>\n<p style=\"padding-left: 30px\">In the App.xaml file<\/p>\n<p style=\"padding-left: 30px\">In a separate resource dictionary XAML file<\/p>\n<p style=\"padding-left: 60px\">Can be shared across apps, and more than one resource dictionary can be merged in a single app).<\/p>\n<p style=\"padding-left: 60px\">Scope is determined by where the resource dictionary is referenced.<\/p>\n\n\n<h5 class=\"wp-block-heading\">Style definitions<\/h5>\n\n\n<p>TargetType attribute<\/p>\n<p style=\"padding-left: 30px\">String that specifies a FrameworkElement type to apply the style to.<\/p>\n<p style=\"padding-left: 30px\">Must specify a FrameworkElement-derived type that&#8217;s defined by the Windows Runtime or a custom type that&#8217;s available in a referenced assembly.<\/p>\n<p style=\"padding-left: 30px\"><em>If you try to apply a style to a control and the control&#8217;s type doesn&#8217;t match the TargetType attribute of the style you&#8217;re trying to apply, an exception occurs.<\/em><\/p>\n<p>Setter elements<\/p>\n<p style=\"padding-left: 30px\">A collection of one or more Setter elements.\u00a0\u00a0Each requires a Property and a Value.<\/p>\n<p>x:Key<\/p>\n<p style=\"padding-left: 30px\">If a style contains the x:Key attribute, you can only apply it to a control by setting the Style property of the control to the keyed style. A style without an x:Key attribute is automatically applied to every control of its target type, that doesn&#8217;t otherwise have an explicit style setting.<\/p>\n\n\n<h5 class=\"wp-block-heading\">Inheriting from other styles<\/h5>\n\n\n\n<p>Use the BasedOn property<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can define a style inline in the XAML for a control, or as a reusable resource. Defining styles as a reusable resource Style definition locations An individual page&#8217;s XAML file (will override a same named resource in App.xaml) Will override a same named resource in App.xaml if present. In the App.xaml file In a [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-785","post","type-post","status-publish","format-standard","hentry","category-styling"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/785","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=785"}],"version-history":[{"count":0,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/785\/revisions"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=785"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}