{"id":417,"date":"2011-07-31T22:49:48","date_gmt":"2011-07-31T22:49:48","guid":{"rendered":"http:\/\/nestor.nestasoft.fr\/?p=417"},"modified":"2012-02-11T11:17:44","modified_gmt":"2012-02-11T11:17:44","slug":"xaml-wpf-silverligth-astuces-2-tag","status":"publish","type":"post","link":"https:\/\/nestasoft.fr\/?p=417","title":{"rendered":"Xaml(WPF &#8211; Silverlight): Astuces 2 &#8211; Tag"},"content":{"rendered":"<p><img decoding=\"async\" class=\"alignleft\" src=\"http:\/\/www.nestor.nestasoft.fr\/wp-content\/uploads\/2011\/07\/xamllogo.jpeg\" alt=\"Xaml\" width=\"10%\" height=\"9%\" \/><br \/>\nDans ce billet, nous allons voir comment utiliser un <b>Tag<\/b> Xaml.<\/p>\n<p><!--more--><\/p>\n<p>Partons du fait que notre application est du type M-V-VM. Dans notre application seuls les administrateurs peuvent acc\u00e9der \u00e0 la page de param\u00e9trage.<\/p>\n<h3>Etape 1 :<\/h3>\n<p>&#8211; Cr\u00e9ons une classe <i>ListeEnum.cs<\/i> contenant l&rsquo;ensemble de nos constantes nomm\u00e9es (liste d&rsquo;\u00e9num\u00e9rateurs).<\/p>\n<pre class=\"brush:csharp\">\r\npublic partial class ListeEnum\r\n{\r\n        public enum Code\r\n        {\r\n            PARAM_GLOBALE,\r\n            PARAM_USER\r\n        }\r\n}\r\n<\/pre>\n<h3>Etape 2 :<\/h3>\n<p>&#8211; Dans le fichier contenant le lien permettant d&rsquo;acc\u00e9der \u00e0 la page de param\u00e9trage (Bien entendu le MainPage.xaml) on \u00e9crira ceci:<\/p>\n<pre class=\"brush:csharp\">\r\n <Border x:Name=\"ParamMenu\" Style=\"{StaticResource MenuBorderStyle}\" Visibility=\"Collapsed\">\r\n\t<HyperlinkButton  x:Name=\"LinkParam\" NavigateUri=\"\/Parametrage\/ListeEnum\" \r\nTargetName=\"ContentFrame\" \r\nStyle=\"{StaticResource LinkStyle}\"\r\n        Content=\"{Binding}\" Tag=\"PARAM_USER\"\/>\r\n<\/Border>\r\n<\/pre>\n<p>Apr\u00e8s avoir v\u00e9rifi\u00e9 l&rsquo;identit\u00e9 du connect\u00e9 et ses habilitations dans la ViewModel, si ce dernier n&rsquo;a pas les habilitations requises, le lien sera verrouill\u00e9 (dans le code behind xaml.cs de la MainPage)<\/p>\n<h3>Etape 3 :<\/h3>\n<pre class=\"brush:csharp\">\r\n    ParamMenu.Visibility = System.Windows.Visibility.Visible;\r\n    VisualStateManager.GoToState(LinkParam, \"InactiveLink\", true);\r\n<\/pre>\n<p>A tr\u00e8s bient\u00f4t pour la prochaine astuce \ud83d\ude42<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_417\" class=\"pvc_stats all  \" data-element-id=\"417\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/nestasoft.fr\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Dans ce billet, nous allons voir comment utiliser un Tag Xaml.<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_417\" class=\"pvc_stats all  \" data-element-id=\"417\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/nestasoft.fr\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-417","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/posts\/417","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=417"}],"version-history":[{"count":14,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/posts\/417\/revisions"}],"predecessor-version":[{"id":1756,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/posts\/417\/revisions\/1756"}],"wp:attachment":[{"href":"https:\/\/nestasoft.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=417"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=417"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=417"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}