{"id":819,"date":"2019-02-15T14:17:35","date_gmt":"2019-02-15T14:17:35","guid":{"rendered":"https:\/\/ibex.tech\/windows-iot\/?p=819"},"modified":"2019-02-15T14:17:35","modified_gmt":"2019-02-15T14:17:35","slug":"styling-a-axml-object","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/uwp-programming-in-c\/styling\/styling-a-axml-object","title":{"rendered":"Styling An AXML Object"},"content":{"rendered":"\n<h5 class=\"wp-block-heading\">Style assignment in the axml file<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>  &lt;TextBlock Hello\" Style=\"{StaticResource MyTextBlockStyleName}\" \/&gt;<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Style definition if in App.xaml<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>        &lt;Style x:Key=\"MyTextBlockStyleName\" TargetType=\"TextBlock\"&gt;\n            &lt;Setter Property=\"FontFamily\" Value=\"Arial\"\/&gt;\n            &lt;Setter Property=\"FontWeight\" Value=\"Bold\"\/&gt;\n            &lt;Setter Property=\"Foreground\" Value=\"White\"\/&gt;\n            &lt;Setter Property=\"FontSize\" Value=\"18\"\/&gt;\n            &lt;Setter Property=\"Height\" Value=\"24\"\/&gt;\n        &lt;\/Style&gt;<\/code><\/pre>\n\n\n\n<p>It needs to be in a Application.Resources section, like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;Application\n    x:Class=\"MyApp.App\"\n    xmlns=\"http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\/presentation\"\n    xmlns:x=\"http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\"\n    xmlns:local=\"using:MyApp\"\n    RequestedTheme=\"Light\"&gt;\n\n    &lt;Application.Resources&gt;\n        &lt;Style x:Key=\"MyTextBlockStyleName\" TargetType=\"TextBlock\"&gt;\n            &lt;Setter Property=\"FontFamily\" Value=\"Arial\"\/&gt;\n            &lt;Setter Property=\"FontWeight\" Value=\"Bold\"\/&gt;\n            &lt;Setter Property=\"Foreground\" Value=\"White\"\/&gt;\n            &lt;Setter Property=\"FontSize\" Value=\"18\"\/&gt;\n            &lt;Setter Property=\"Height\" Value=\"24\"\/&gt;\n        &lt;\/Style&gt;\n        \n        Other styles...\n        \n    &lt;\/Application.Resources&gt;\n\n&lt;\/Application&gt;<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Style definition if in the axml file<\/h5>\n\n\n\n<p>Typically placed before the &lt;grid&gt;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;ContentDialog.Resources&gt;\n    &lt;Style x:Key=\"MyTextBlockStyleName\" TargetType=\"TextBlock\"&gt;\n        &lt;Setter Property=\"FontFamily\" Value=\"Arial\"\/&gt;\n        &lt;Setter Property=\"FontWeight\" Value=\"Bold\"\/&gt;\n        &lt;Setter Property=\"Foreground\" Value=\"White\"\/&gt;\n        &lt;Setter Property=\"FontSize\" Value=\"18\"\/&gt;\n        &lt;Setter Property=\"Height\" Value=\"24\"\/&gt;\n    &lt;\/Style&gt;\n&lt;\/ContentDialog.Resources&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Style assignment in the axml file Style definition if in App.xaml It needs to be in a Application.Resources section, like this: Style definition if in the axml file Typically placed before the &lt;grid&gt;<\/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-819","post","type-post","status-publish","format-standard","hentry","category-styling"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/819","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=819"}],"version-history":[{"count":0,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/819\/revisions"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=819"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=819"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}