2012-11-15 5 views
1

내 앱을 실행할 때 예외가 발생합니다. 나는 XAML로 이동 디버거는이 메시지와 함께 밖으로 종료 :예외 : DrawingSurfaceBackgroundGrid가 그리기를 시작하는 첫 번째 요소 여야합니다.

DrawingSurfaceBackgroundGrid이 도면을 시작하는 첫 번째 요소해야합니다.

내 MainPage.xaml에서 MainPage.xaml에서 버튼을 클릭하면이 DirectX.xaml 파일로 이동합니다. DrawingSurfaceBackgroundGrid가 유일한 컨트롤인지 확인 했으므로 FIRST 요소입니다. 주문을 잘못 받았습니까?

DirectX.xaml

<phone:PhoneApplicationPage 
    x:Class="GameWp8Dx.Hud.Tests.DirectX" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" 
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    FontFamily="{StaticResource PhoneFontFamilyNormal}" 
    FontSize="{StaticResource PhoneFontSizeNormal}" 
    Foreground="{StaticResource PhoneForegroundBrush}" 
    SupportedOrientations="Portrait" Orientation="Portrait" 
    mc:Ignorable="d" 
    shell:SystemTray.IsVisible="True"> 

    <!--LayoutRoot is the root grid where all page content is placed--> 
    <DrawingSurfaceBackgroundGrid x:Name="DrawingSurfaceBackground" Loaded="DrawingSurfaceBackground_Loaded"> 
    </DrawingSurfaceBackgroundGrid> 

</phone:PhoneApplicationPage> 

에서 MainPage.xaml

<phone:PhoneApplicationPage 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" 
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" 
    xmlns:local="clr-namespace:GameWp8Dx" 
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:ec="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" 
    x:Class="GameWp8Dx.MainPage" 
    mc:Ignorable="d" 
    FontFamily="{StaticResource PhoneFontFamilyNormal}" 
    FontSize="{StaticResource PhoneFontSizeNormal}" 
    Foreground="{StaticResource PhoneForegroundBrush}" 
    SupportedOrientations="Portrait" Orientation="Portrait" 
    shell:SystemTray.IsVisible="True" 
    local:TiltEffect.IsTiltEnabled="True" 
    ApplicationBar="{StaticResource socialAppBar}" 
    > 

    <!--Transitions--> 
    <toolkit:TransitionService.NavigationInTransition> 
     <toolkit:NavigationInTransition> 
      <toolkit:NavigationInTransition.Backward> 
       <toolkit:TurnstileTransition Mode="BackwardIn"/> 
      </toolkit:NavigationInTransition.Backward> 
      <toolkit:NavigationInTransition.Forward> 
       <toolkit:TurnstileTransition Mode="ForwardIn"/> 
      </toolkit:NavigationInTransition.Forward> 
     </toolkit:NavigationInTransition> 
    </toolkit:TransitionService.NavigationInTransition> 

<!--LayoutRoot is the root grid where all page content is placed--> 
    <Grid x:Name="LayoutRoot"> 

     <phone:Panorama x:Name="test" HorizontalAlignment="Left" Height="686" VerticalAlignment="Top" Width="470" 
      Title="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource ResourceKey=LocalizedStrings}}" TitleTemplate="{StaticResource MainPageTitleTemplate}" HeaderTemplate="{StaticResource MainPageHeaderTemplate}"> 

App.xaml

(또한 여기에 표시된 내 App.xaml 및 MainPage.xaml을 수 있습니다)
<Application 
    x:Class="GameWp8Dx.App" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" 
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"> 

    <!--Application Resources--> 
    <Application.Resources> 

     <ResourceDictionary> 
      <ResourceDictionary.MergedDictionaries> 
       <ResourceDictionary Source="CustomStyles.xaml"/> 
      </ResourceDictionary.MergedDictionaries> 

      <local:LocalizedStrings xmlns:local="clr-namespace:GameWp8Dx" x:Key="LocalizedStrings"/> 

      <shell:ApplicationBar x:Key="inGameAppBar" IsVisible="True" IsMenuEnabled="False"> 
       <shell:ApplicationBarIconButton IconUri="/Assets/Icons/microphone.png" Text="record" Click="record_Click"/> 
       <shell:ApplicationBarIconButton IconUri="/Assets/Icons/questionmark.png" Text="info"/> 
       <shell:ApplicationBarIconButton IconUri="/Assets/Icons/map.png" Text="map" Click="map_Click"/>    
      </shell:ApplicationBar> 
      <shell:ApplicationBar x:Key="socialAppBar" IsVisible="True" IsMenuEnabled="False"> 
       <shell:ApplicationBarIconButton IconUri="/Assets/Icons/appbar.twitter.png" Text="Tweet" Click="OnTweet"/> 
       <shell:ApplicationBarIconButton IconUri="/Assets/Icons/appbar.twitter.bird.png" Text="Tweet" Click="OnTweetSharp"/> 
       <shell:ApplicationBarIconButton IconUri="/Assets/Icons/appbar.facebook.png" Text="Share" Click="OnShare"/> 
       <shell:ApplicationBarIconButton IconUri="/Assets/Icons/appbar.facebook.heart.png" Text="Like" Click="OnLike"/> 
      </shell:ApplicationBar> 
     </ResourceDictionary> 
    </Application.Resources> 

    <Application.ApplicationLifetimeObjects> 
     <!--Required object that handles lifetime events for the application--> 
     <shell:PhoneApplicationService 
      Launching="Application_Launching" Closing="Application_Closing" 
      Activated="Application_Activated" Deactivated="Application_Deactivated"/> 
    </Application.ApplicationLifetimeObjects> 
</Application> 

UPDATE

가 범인입니다) (TransitionFrame를 밝혀! PhoneApplicationPage()로 다시 변경하고 DrawingSurfaceBackgroundGrid는 장애없이 작동합니다.

App.xaml.cs를

private void InitializePhoneApplication() 
{ 
    if (phoneApplicationInitialized) 
     return; 

    // Create the frame but don't set it as RootVisual yet; this allows the splash 
    // screen to remain active until the application is ready to render. 
    RootFrame = new TransitionFrame(); 
    //RootFrame = new PhoneApplicationFrame(); 
    RootFrame.Navigated += CompleteInitializePhoneApplication; 

    // Handle navigation failures 
    RootFrame.NavigationFailed += RootFrame_NavigationFailed; 

    // Handle reset requests for clearing the backstack 
    RootFrame.Navigated += CheckForResetNavigation; 

    // Ensure we don't initialize again 
    phoneApplicationInitialized = true; 
} 

답변

3

난 그냥 여기 추측하고있어,하지만 당신은 특별한 TransitionFrame에의 RootFrame을 변경 했습니까? 그렇다면 DrawingSurfaceBackgroundGrid와 잘 작동하지 않는다고 가정합니다. 아마도 DrarwingSurface로 변경하여이 문제를 해결할 수 있습니다. 그러나 DrawingSurface는 XAML과 섞어 사용되는 중간 드로잉 레이어로 인해 화면에 표시된 모든 DirectX 콘텐츠를 추가로 오버 드로합니다. 따라서 전체 페이지 D3D 콘텐츠에 DrawingSurface를 사용하면 성능 문제가 발생할 수 있습니다 (HD 해상도 화면의 경우 훨씬 그렇습니다).

문제를 이해하려면 DrawingSufaceBackgroundGrid가있는 페이지를 탐색 할 때 어떤 일이 일어나는지 생각해보십시오. 그것은 움직일 것인가? 그렇다면 XAML 애니메이션을 D3D 콘텐트에 적용해야하며 DrawingSurfaceBackgroundGrid에는 지원되지 않습니다. DrawingSurface는 지원되지만 XAML과 엇갈리게 사용되는 중간 드로잉 레이어가 필요합니다.

나쁜 DirectX 성능과 부족한 페이지 전환 사이의 상반 관계에서 페이지 전환을 선택하지 않을 것이라고 생각합니다. 즉, 다른 앱은 서로 다른 타협점을 가질 것입니다.

다른 생각으로는 전체 화면 D3D가 필요한지 여부에 따라 표준 PhoneApplicationFrame과 TransitionFrame간에 전환 할 수 있습니다. 나는 그런 것을 테스트하지 않았다.

+0

JustinAngel에게 감사드립니다. 팀의 누군가가 RootFrame을 PhoneApplicationFrame에서 TransitionFrame으로 변경했습니다. 이것은 꽤 절충점입니다. 나는 그러한 페이지 전환을 좋아합니다. 그러나 당신의 마지막 생각은 재미 있습니다. 나는 그것을 시험해야 할 것입니다. – Lisa

+0

안녕하세요 저스틴, XAML과 엇갈려 짜는 중개 드로잉 레이어 란 무엇입니까?이 문제에 대해 자세히 설명해 주시겠습니까? –