title: XAML - How to declare Behaviours at Page or App level
body: <p>I've added the following behaviours to a custom user control in a WinPhone8.1 App using Blend:</p>
  
  <pre><code>&lt;Interactivity:Interaction.Behaviors&gt;
              &lt;Core:EventTriggerBehavior x:Name="Pressed" EventName="PointerPressed"&gt;
                  &lt;Core:ChangePropertyAction PropertyName="Background"&gt;
                      &lt;Core:ChangePropertyAction.Value&gt;
                          &lt;SolidColorBrush Color="#FF75807F"/&gt;
                      &lt;/Core:ChangePropertyAction.Value&gt;
                  &lt;/Core:ChangePropertyAction&gt;
              &lt;/Core:EventTriggerBehavior&gt;
              &lt;Core:EventTriggerBehavior x:Name="Released" EventName="PointerCaptureLost"&gt;
                  &lt;Core:ChangePropertyAction PropertyName="Background"/&gt;
              &lt;/Core:EventTriggerBehavior&gt;
          &lt;/Interactivity:Interaction.Behaviors&gt;
  </code></pre>
  
  <p>This line was also added to my UserControl XAML:</p>
  
  <pre><code>xmlns:Interactivity="using:Microsoft.Xaml.Interactivity" xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
  </code></pre>
  
  <p>This is fine and it works well. I was hoping to move this code into App.xaml so I could add the behaviours on to different Grids.</p>
  
  <p>I moved the "using" statement to the App.xaml file: <code>
      xmlns:Interactivity="using:Microsoft.Xaml.Interactivity" xmlns:Core="using:Microsoft.Xaml.Interactions.Core"</code> and also the Style:</p>
  
  <pre><code>&lt;Style TargetType="Grid" x:Key="ClickableGrid2" &gt;
  &lt;Interactivity:Interaction.Behaviors&gt;
      &lt;Core:EventTriggerBehavior x:Name="Pressed" EventName="PointerPressed"&gt;
          &lt;Core:ChangePropertyAction PropertyName="Background"&gt;
              &lt;Core:ChangePropertyAction.Value&gt;
                  &lt;SolidColorBrush Color="#FF75807F"/&gt;
              &lt;/Core:ChangePropertyAction.Value&gt;
          &lt;/Core:ChangePropertyAction&gt;
      &lt;/Core:EventTriggerBehavior&gt;
      &lt;Core:EventTriggerBehavior x:Name="Released" EventName="PointerCaptureLost"&gt;
          &lt;Core:ChangePropertyAction PropertyName="Background"/&gt;
      &lt;/Core:EventTriggerBehavior&gt;
  &lt;/Interactivity:Interaction.Behaviors&gt;
  </code></pre>
  
  <p></p>
  
  <p>I also referenced the style in my Grid:</p>
  
  <pre><code>&lt;Grid x:Name="QuestionGrid" Background="White" Style="{StaticResource ClickableGrid2}"&gt;
      controls omitted...
  &lt;/Grid&gt;
  </code></pre>
  
  <p>The code compiles but when I run in debug mode I get the following error as soon as the app starts:</p>
  
  <blockquote>
    <p>Cannot deserialize XBF metadata type list as '%1' was not found in namespace '%0'. [Line: 0 Position: 0]</p>
  </blockquote>
  
  <p>There's no inner exception. There's not much detail, but I'm assuming the error is related to the "using" statements I added to the App.xaml file - but I'm not sure...?</p>
  
  <p>I would assume Behaviours can be added at the app level but Google doesn't return any good examples of this being done. I have added simple Styles at app level and they work fine.</p>
  
  <p>My question is: Can I add behaviours in this way, and if I can, where am I going wrong?</p>