2011-02-06 20 views
2

我希望有人能有什麼應該是解決...我已經花了幾個小時就這是一個非常簡單的問題,幫助它只是讓我瘋了!Windows Phone 7 - 如何將大於屏幕的滾動查看器中的彈出窗口居中?

在我的Silverlight WP7應用程序中,我有一個600x600的ScrollViewer控件,並向左偏移60像素(水平居中),並且在這個對象上疊加了多個圖像(請參閱下面的代碼) 。

我也有一個Popup控件定義,當圖片從網上下載時彈出,但我不能讓PopUp居中 - 甚至更糟糕的是,它裏面的文本從來沒有居中,即使我已經指定它是......它總是證明留下不管我試試。

<Grid x:Name="LayoutRoot" Background="Transparent"> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="40"/> 
      <RowDefinition Height="600"/> 
      <RowDefinition Height="50"/> 
      <RowDefinition Height="*"/> 
     </Grid.RowDefinitions> 

     <ScrollViewer Grid.Row="1" Margin="-60,0,0,0" Height="600" Width="600" VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Auto">    
      <Grid x:Name="RadarImages" Margin="0,0,0,0">    
       <Image Height="600" Margin="0,0,0,0" HorizontalAlignment="Left" Name="imgBack" Stretch="Fill" VerticalAlignment="Top" Width="600" Opacity="100" /> 
       <Image Height="600" Margin="0,0,0,0" HorizontalAlignment="Left" Name="imgObs" Stretch="Fill" VerticalAlignment="Top" Width="600" Opacity="100" /> 
       <Image Height="600" Margin="0,0,0,0" HorizontalAlignment="Left" Name="imgLoop" Stretch="Fill" VerticalAlignment="Top" Width="600" Opacity="100" /> 
       <Popup x:Name="StatusPopup" Margin="-200,-100,0,0" HorizontalAlignment="Center" VerticalAlignment="Center"> 
        <TextBox Text="...loading..." Width="200" Height="60" HorizontalAlignment="Center" VerticalAlignment="Center" Background="Black" Foreground="White" BorderBrush="White" BorderThickness="3" /> 
       </Popup> 
      </Grid> 
     </ScrollViewer> 

    </Grid> 

我試着將彈出內部網格明確地控制沒有快樂的佈局:在彈出該死的就不會居中在屏幕上,裏面的文字也不會。

任何人都可以提出什麼,我需要做什麼來解決這個問題?

TIA ...

邁克

回答

1

我已經成功使用以下XAML來獲得Popup內容(我加了幾個固定的背景顏色來顯示不同的元件):

<Grid x:Name="LayoutRoot" Background="Transparent"> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="40"/> 
      <RowDefinition Height="600"/> 
      <RowDefinition Height="50"/> 
      <RowDefinition Height="*"/> 
     </Grid.RowDefinitions> 

     <ScrollViewer Grid.Row="1" Margin="-60,0,0,0" Height="600" Width="600" VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Auto">    
      <Grid x:Name="RadarImages" Background="AliceBlue" Margin="0,0,0,0">    
       <Image Height="600" Margin="0,0,0,0" HorizontalAlignment="Left" Name="imgBack" Stretch="Fill" VerticalAlignment="Top" Width="600" Opacity="1" /> 
       <Image Height="600" Margin="0,0,0,0" HorizontalAlignment="Left" Name="imgObs" Stretch="Fill" VerticalAlignment="Top" Width="600" Opacity="1" /> 
       <Image Height="600" Margin="0,0,0,0" HorizontalAlignment="Left" Name="imgLoop" Stretch="Fill" VerticalAlignment="Top" Width="600" Opacity="1" /> 
       <Popup x:Name="StatusPopup" IsOpen="True"> 
        <Border Background="Red" Height="768" Margin="60,0" Width="480"> 
         <TextBox Text="...loading..." HorizontalAlignment="Center" VerticalAlignment="Center" Background="Black" Foreground="White" BorderBrush="White" BorderThickness="3" /> 
        </Border> 
       </Popup> 
      </Grid> 
     </ScrollViewer> 

    </Grid>

Bascially,您不能使用Popup本身位置或對齊,你與Popup而不是內部的根元素的工作。

的另一件事:值的Opacity的有效範圍是0到1,而不是100。

+0

謝謝德里克,該工程* *得多好!在上面的示例代碼中,爲什麼imgLoop會設置爲「1010」?這是一個錯字還是我錯過了什麼? – nzmike 2011-02-08 06:04:15