2016-11-16 6 views
0

내 인터페이스가 모든 전화 화면 해상도에 맞도록 만들려고했기 때문에 ViewBox를 사용하는 것이 좋았습니다. 콘텐츠를 크기 조정해야하기 때문에 모든 요소가있는 Canvas를 래핑 할 때마다 문제가 발생했습니다. 이 같은 뷰 박스 :ViewBox에서 UWP 앱이 깨졌습니다.

 <Viewbox Stretch="Uniform" > 
     <Canvas x:Name="canvas"> 
     <Canvas.Background> 
      <ImageBrush Stretch="Uniform" ImageSource="Assets/start-01.jpg"/> 
     </Canvas.Background> 
       <Image x:Name="play" HorizontalAlignment="Left" Height="36" Margin="70,271,0,0" VerticalAlignment="Top" Width="194" Source="Assets/start bottuns-01.png" Stretch="Fill" Tapped="play_Tapped"/> 
       <TextBlock x:Name="playTB" Height="36" Margin="117,265,221,0" TextWrapping="Wrap" Text="RACE" FontSize="30" VerticalAlignment="Top" CharacterSpacing="364" Tapped="play_Tapped" FontFamily="Lucida Sans Unicode"/> 
       <Image x:Name="highscoresBT" HorizontalAlignment="Left" Height="36" Margin="70,337,0,0" VerticalAlignment="Top" Width="194" Source="Assets/start bottuns-01.png" Stretch="Fill" Tapped="highscoresBT_Tapped"/> 
       <TextBlock x:Name="highscoreTB" Height="36" Margin="72,337,236,0" TextWrapping="Wrap" Text="HIGHSCORES" FontSize="24" VerticalAlignment="Top" CharacterSpacing="194" Tapped="highscoresBT_Tapped" FontFamily="Lucida Sans Unicode"/> 
       <Image x:Name="storeBT" HorizontalAlignment="Left" Height="36" Margin="70,403,0,0" VerticalAlignment="Top" Width="194" Source="Assets/start bottuns-01.png" Stretch="Fill" Tapped="storeBT_Tapped"/> 
       <TextBlock x:Name="storeTB" HorizontalAlignment="Left" Height="36" Margin="111,397,0,0" TextWrapping="Wrap" Text="STORE" Width="151" FontSize="30" VerticalAlignment="Top" CharacterSpacing="364" Tapped="storeBT_Tapped"/> 
       <Image x:Name="helpBut" HorizontalAlignment="Left" Height="100" Margin="131,522,0,0" VerticalAlignment="Top" Width="72" Source="Assets/helpBut-01.png" Tapped="helpBut_Tapped"/> 
       <Image x:Name="coinsBG" HorizontalAlignment="Left" Height="19" Margin="282,0,0,0" VerticalAlignment="Top" Width="56" Source="Assets/comp bar-01.png" Stretch="Fill"/> 
       <Image x:Name="coinsIC" HorizontalAlignment="Left" Height="19" VerticalAlignment="Top" Width="14" Source="Assets/coins-01.png" Margin="316,1,0,0"/> 
       <TextBlock x:Name="coinsOwnedTB" HorizontalAlignment="Left" Height="14" Margin="290,2,0,0" TextWrapping="Wrap" Text="120" VerticalAlignment="Top" Width="21" FontSize="10" FontFamily="Lucida Sans Unicode" Foreground="#FF535257"/> 
       <Image x:Name="scoreBG" HorizontalAlignment="Left" Height="23" VerticalAlignment="Top" Width="136" Source="Assets/comp bar-01.png" Stretch="Fill"/> 
       <TextBlock x:Name="scoreNameTB" HorizontalAlignment="Left" Height="21" Margin="1,2,0,0" TextWrapping="Wrap" Text="Score: " VerticalAlignment="Top" Width="48" FontSize="14" FontFamily="Lucida Sans Unicode" Foreground="#FF535257"/> 
       <TextBlock x:Name="scoreTB" HorizontalAlignment="Left" Height="21" Margin="49,2,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="87" FontSize="14" FontFamily="Lucida Sans Unicode" Foreground="#FF535257"/> 
       <Image x:Name="feedbackBT" HorizontalAlignment="Left" Height="36" Margin="70,469,0,0" VerticalAlignment="Top" Width="194" Source="Assets/start bottuns-01.png" Stretch="Fill" Tapped="feedback_Tapped"/> 
       <TextBlock x:Name="feedbackTB" Height="36" Margin="83,463,244,0" TextWrapping="Wrap" Text="SUPPORT" FontSize="30" VerticalAlignment="Top" Tapped="feedback_Tapped" FontFamily="Lucida Sans Unicode" TextAlignment="Center" CharacterSpacing="200"/> 
    </Canvas> 
    </Viewbox> 

모든 요소가 사라지고 전화 에뮬레이터에서 실행되는 경우 응용 프로그램은 사람이 어떤 생각을 가지고 충돌?

참고 : 캔버스 대신 그리드를 사용하면 문제가 해결되지만 캔버스를 사용해야하는 응용 프로그램의 일부 위치에서 ViewBox와 동일한 문제가 발생하므로이 질문을 예제로 게시했습니다.이 페이지를 알고 있습니다. Canvas가 실제로 필요하지 않습니다. 감사합니다

답변

0

글쎄 캔버스가보기 상자에서 제대로 볼 수있는 높이와 너비가 있어야한다는 사실이 밝혀졌습니다. 그리드에는 캔버스가없는 동안 그리드가 요소의 크기를 차지하므로 실제로는 논리적입니다. '티.

캔버스의 높이와 너비를 설정하지 않고 ViewBox를 추가 할 때 전화 에뮬레이터에서 App이 충돌하는 이유는 무엇입니까?하지만 설정 한 경우 정상적으로 작동합니다.