define a style for a button in code behind UWP app
<p>I tried to apply a style for my button in the code behind,like this:</p>

<p>using Windows.UI.Xaml.Markup;</p>

<pre><code> MenuButton2.Style = ButtonStyle();

     private Style ButtonStyle()
            {
                string xaml =
                  "&lt;Style  " +
"xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' " +
                    "xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' " +
                    "xmlns:d = 'http://schemas.microsoft.com/expression/blend/2008' " +
                    "TargetType='Button'&gt;" +
                     "&lt;Setter Property='Foreground' Value='#e6e6e6'/&gt;" +
                   " &lt; Setter Property = 'Template' &gt;" +
                    " &lt; Setter.Value &gt;" +
                         "&lt; ControlTemplate TargetType = 'Button' &gt;" +
                              "&lt; Grid &gt;" +
                                  "&lt; VisualStateManager.VisualStateGroups &gt;" +
                                      "&lt; VisualStateGroup x: Name = 'CommonStates' &gt;" +
                                            "&lt; VisualState x: Name = 'Normal' /&gt;" +
                                              "&lt; VisualState x: Name = 'PointerOver' &gt;" +
                                                   " &lt; Storyboard &gt;" +
                                                        "&lt; ColorAnimation Duration = '0' To = '#e6e6e6' Storyboard.TargetProperty = '(Rectangle.Fill).(SolidColorBrush.Color)' Storyboard.TargetName = 'Button' /&gt;" +
                                                           "&lt;/ Storyboard &gt;" +
                                                       "&lt;/ VisualState &gt;" +
                                                       "&lt; VisualState x: Name = 'Pressed' &gt;" +
                                                            " &lt; Storyboard &gt;" +
                                                                    " &lt; ColorAnimation Duration = '0' To = '#e6e6e6' Storyboard.TargetProperty = '(Rectangle.Fill).(SolidColorBrush.Color)' Storyboard.TargetName = 'Button' /&gt;" +
                                                                        "&lt; ColorAnimation Duration = '0' To = '#e6e6e6' Storyboard.TargetProperty = '(TextBlock.Foreground).(SolidColorBrush.Color)' Storyboard.TargetName = 'Content' /&gt;" +
                                                                           "&lt;/ Storyboard &gt; " +
                                                                      " &lt;/ VisualState &gt;" +
                                                                  " &lt;/ VisualStateGroup &gt;" +
                                                              " &lt;/ VisualStateManager.VisualStateGroups &gt;" +
                                                               "&lt; Grid &gt;" +
                                                                  " &lt; Rectangle x: Name = 'Button' Stroke = 'Transparent' Fill = 'Transparent' Margin = '0' /&gt;" +
                                                                          " &lt; ContentPresenter x: Name = 'Content' /&gt;" +
                                                                         "&lt;/ Grid &gt;" +
                                                                       " &lt;/ Grid &gt;" +
                                                                 "&lt;/ ControlTemplate &gt;" +
                                                            " &lt;/ Setter.Value &gt;" +
                                                        " &lt;/ Setter &gt;" +
                                                          "&lt;/Style&gt;";
                return (Style)Windows.UI.Xaml.Markup.XamlReader.Load(xaml);
            }
</code></pre>

<p>but I have a problem when I execute my app,this is the error I get:</p>

<p>An exception of type 'Windows.UI.Xaml.Markup.XamlParseException' occurred in App.exe but was not handled in user code
 WinRT information: illegal qualified name character [Line: 1 Position: 262]
 Additional information: The text associated with this error code is not found.</p>

<p>thanks for help</p>