2012-01-26 14 views
1

私はSLXNAゲームを持っており、SL部分にメニューを表示しようとしています。問題は、ボタンが表示されるように見えるが、完全には表示されないように見えることである画面の特定の部分では、ボタンが描かれなくなります(私はボタンが見えるところまでtjeボタンが見えます)。何が問題なの?SLXNAでディスプレイ全体のボタンをレンダリングできません

注:アプリは風景の中にあるとされ、デフォルトSL/XNAテンプレート

ここでは、コードは(私は私たちだけの興味のあるコードが表示されます)です。

XAML:

</Grid.RowDefinitions> 

    <!-- Toggles the visibility of the ColorPanel --> 
    <Button VerticalAlignment="Top" BorderBrush="DarkRed" Foreground="DarkRed" Margin="1,0,-1,0">pause</Button> 
    <Button VerticalAlignment="Bottom" BorderBrush="DarkRed" Foreground="DarkRed" Margin="1,0,-1,0">change</Button> 

    <!-- Arrange buttons in a horizontal line by using StackPanel --> 

</Grid> 

私は宣言する:

UIElementRenderer elementRenderer; 

public GamePage() 
     { 
      // some typical code..... 

      LayoutUpdated += new EventHandler(GamePage_LayoutUpdated); 
     } 


void GamePage_LayoutUpdated(object sender, EventArgs e) 
     { 
      // Create the UIElementRenderer to draw the XAML page to a texture. 

      // Check for 0 because when we navigate away the LayoutUpdate event 
      // is raised but ActualWidth and ActualHeight will be 0 in that case. 
      if (ActualWidth > 0 && ActualHeight > 0 && elementRenderer == null) 
      { 

       elementRenderer = new UIElementRenderer(this, (int)ActualWidth, (int)ActualHeight); 
      } 
     } 

private void OnDraw(object sender, GameTimerEventArgs e) 
     { 
      SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.LightGoldenrodYellow); 

      // draw some 3d objects 

      elementRenderer.Render(); 

      spriteBatch.Begin(); 
      spriteBatch.Draw(elementRenderer.Texture, Vector2.Zero, Color.White); 

      spriteBatch.End(); 


      // TODO: Add your drawing code here 
     } 
+0

(すなわち、あなたは再びGamePage_LayoutUpdated方法で持っているコードを呼び出す):どのような画面の向きますが、ここで使用している - あなたはオリエンテーションを動的に変更することができていますか? SharedGraphicsDeviceManagerを設定するために標準SL/XNAテンプレートプロジェクトを使用していますか? –

+0

@PaulAnnetts標準のSL/XNAテンプレートを使用していますが、向きはランドスケープのみです – Alex

答えて

1

これまではこれを見てきました。私はここの問題は、あなたのページが横向きなので、実際にSilverlightによってPortraitとして最初に作成された後、 "回転"して間違ったサイズとすべてが間違っていることがあなたのUIElementRendererを残していることです。

OrientationChangedイベントに応答して、あなたのUIElementRendererを再作成してください。質問のカップル

+0

オリエンテーションのイベントハンドラを追加してコードを再度呼び出しましたが、動作しませんでした。 elementRenderer = new UIElementRenderer(this、(int)ActualWidth、(int)ActualHeight)で、ActualHeightとActualWidthを逆にして修正することができました。コード。ありがとう! – Alex

関連する問題