2012-03-05 8 views
0

を制御し、私のフレームサイズは、WPFウィンドウのサイズを取得し、コードは次のとおりです。フレームページは、私が間違っている場所を教えてくださいでしたレイアウト

<Window x:Class="MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="BSP" Height="700" Width="990" WindowStartupLocation="CenterScreen"> 
    <Grid Background="Green" VerticalAlignment="Center" HorizontalAlignment="Center" > 
      <Frame Name="MainFrame" Source="LoginScreen.xaml" NavigationUIVisibility="Hidden" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />   
    </Grid> 
</Window> 

ウィンドウよりも少ないページサイズとも合計余白のサイズ+幅+ラベルのサイズがページのサイズより小さく、ボタンがカットとして表示されています。ページのコード以下の通りです:

<Page x:Class="Loggedin" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     mc:Ignorable="d" 
     Height="660" Width="920" 
     Title="Loggedin"> 
     <Grid Background="white" Margin="2"> 
     <StackPanel Orientation="Horizontal" VerticalAlignment="Top" > 
      <Label Content="Loggedin as" Height="28" HorizontalAlignment="Left" Name="Loggedinas" /> 
      <Button Content="LogOut" Margin="780,0,0,0" Height="28" Name="Logout" Width="50" HorizontalAlignment="Right"/> 
     </StackPanel> 
     </Grid> 
</Page> 

あなたは私を支援してもらえ、それは2日:(から私の脳を食べている次の出力の写真です:。 ピックビジュアルスタジオから:http://clip2net.com/s/1Fpb7

picからランタイム:http://clip2net.com/s/1FpbQ

答えて

1

があなたの代わりにのStackPanelのDockPanelを使用する方法について考えたことがありますあなたが達成しようとしているレイアウトの近くにフィットするようだ:?

<DockPanel VerticalAlignment="Top"> 
     <Label Content="Loggedin as" Height="28" HorizontalAlignment="Left" Name="Loggedinas" /> 
     <Button Content="LogOut" Height="28" Name="Logout" Width="50" HorizontalAlignment="Right"/> 
    </DockPanel> 

Margin="780,0,0,0"のような余白がある場合は、通常、あまりにも難しい作業をしていることを意味し、それを行うには良い方法があります。私のクイックスクラッチテストでは、780ピクセルの左余白がフレームからボタンを押していました。

+0

これは、フレームの水平方向と垂直方向のアライメントをストレッチするように設定するために、小さな変更にも役立ちました。答えてくれてありがとう。 – surpavan

関連する問題