title: WP8.1 Popup - Slow to render
body: <p>I made a popup control that can accept any view of type <code>FrameworkElement</code>. In addition, you can provide a view model, which will be bound to the <code>DataContext</code> of the child view being provided. Everything works, but it takes a couple of seconds to render the data. The view model has an <code>ObservableCollection</code> that contains about 300 items. So in all honesty, 300 items shouldn't cause any issues.</p>
  
  <p>There is no lag what so ever, If I extract the xaml from the popup to a regular page.</p>
  
  <p>So, is there something inside a <code>Popup</code> control that happens when it's <code>Child</code> content property is being set, that would cause such a delay? Because this is blowing my mind at the moment.</p>
  
  <p>Thanks in advance!</p>
  
  <p>[Update]
  As requested, the XAML that forms the child content of the tool window:</p>
  
  <pre><code>&lt;UserControl
      x:Class="App.Controls.ContactSelector"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="using:App.Controls"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
      xmlns:core="using:Microsoft.Xaml.Interactions.Core"
      mc:Ignorable="d" x:Name="contactSelector"
      DataContext="{Binding ContactSelectorViewModel,Source={StaticResource Locator}}"&gt;
  
      &lt;Grid HorizontalAlignment="Stretch" Style="{StaticResource BaseGridStyle}"&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="1*" /&gt;
              &lt;RowDefinition Height="Auto" /&gt;
          &lt;/Grid.RowDefinitions&gt;
  
          &lt;ListView Grid.Row="0" ItemsSource="{Binding ContactCollection}"&gt;
              &lt;ListView.ItemTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;Grid Margin="12"&gt;
                          &lt;Grid.RowDefinitions&gt;
                              &lt;RowDefinition Height="Auto" /&gt;
                              &lt;RowDefinition Height="Auto" /&gt;
                          &lt;/Grid.RowDefinitions&gt;
                          &lt;Grid.ColumnDefinitions&gt;
                              &lt;ColumnDefinition Width="Auto" /&gt;
                              &lt;ColumnDefinition Width="1*" /&gt;
                          &lt;/Grid.ColumnDefinitions&gt;
                          &lt;!--&lt;Image Margin="0,0,10,0" Grid.Row="0" Grid.Column="0"
                                 Source="{Binding Thumbnail}" MaxHeight="35"
                                 Visibility="{Binding Thumbnail, Converter={StaticResource ObjectNullToVisibilityConverter}}" /&gt;--&gt;
                          &lt;!--&lt;Image Margin="0,5,5,5" Grid.Row="0" Grid.Column="0" MaxHeight="35"
                                 Source="ms-appx:///Assets/Images/Contact.png"
                                 Visibility="{Binding Thumbnail, Converter={StaticResource InverseObjectNullToVisibilityConverter}}" /&gt;--&gt;
  
                          &lt;TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding FullName}"
                                     VerticalAlignment="Center"
                                     Style="{StaticResource TextBlockMedium}" /&gt;
  
                          &lt;!--&lt;Grid Grid.Row="1" Grid.Column="1"&gt;
                              &lt;Grid.RowDefinitions&gt;
                                  &lt;RowDefinition Height="Auto" /&gt;
                              &lt;/Grid.RowDefinitions&gt;
                              &lt;ItemsControl Grid.Row="0" ItemsSource="{Binding MobileNumbers}"&gt;
                                  &lt;ItemsControl.ItemTemplate&gt;
                                      &lt;DataTemplate&gt;
                                          &lt;Grid Margin="10,5"&gt;
                                              &lt;Grid.ColumnDefinitions&gt;
                                                  &lt;ColumnDefinition Width="1*" /&gt;
                                              &lt;/Grid.ColumnDefinitions&gt;
                                              &lt;TextBlock Grid.Column="0" Margin="0"
                                                         Text="{Binding Number}"
                                                         HorizontalAlignment="Stretch"
                                                         Style="{StaticResource TextBlockMedium}"&gt;
                                                  &lt;interactivity:Interaction.Behaviors&gt;
                                                      &lt;core:EventTriggerBehavior EventName="Tapped"&gt;
                                                          &lt;core:InvokeCommandAction
                                                              Command="{Binding DataContext.SelectContact, ElementName=contactSelector}"
                                                              CommandParameter="{Binding}" /&gt;
                                                      &lt;/core:EventTriggerBehavior&gt;
                                                  &lt;/interactivity:Interaction.Behaviors&gt;
                                              &lt;/TextBlock&gt;
                                          &lt;/Grid&gt;
                                      &lt;/DataTemplate&gt;
                                  &lt;/ItemsControl.ItemTemplate&gt;
                              &lt;/ItemsControl&gt;
                          &lt;/Grid&gt;--&gt;
                      &lt;/Grid&gt;
                  &lt;/DataTemplate&gt;
              &lt;/ListView.ItemTemplate&gt;
              &lt;!--&lt;ListView.GroupStyle&gt;
                  &lt;GroupStyle&gt;
                      &lt;GroupStyle.HeaderTemplate&gt;
                          &lt;DataTemplate&gt;
                              &lt;Border&gt;
                                  &lt;TextBlock Text="{Binding Key}"
                                             VerticalAlignment="Center" HorizontalAlignment="Center"
                                             Style="{StaticResource TextBlockMedium}"
                                             Padding="5" Margin="5" FontWeight="SemiBold" /&gt;
                              &lt;/Border&gt;
                          &lt;/DataTemplate&gt;
                      &lt;/GroupStyle.HeaderTemplate&gt;
                  &lt;/GroupStyle&gt;
              &lt;/ListView.GroupStyle&gt;--&gt;
          &lt;/ListView&gt;
  
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>So I have commented out the entire section of the <code>ItemsControl</code>, but this did not solve the problem. When the <code>Popup</code> opens, it still takes quite a while to show the containing items.</p>
  
  <p>It isn't slow when it's scrolling, it's slow in rendering the initial items.</p>