2013-10-18 53 views
0

問題是圖像不固定在屏幕的右側,所以當我調整屏幕形象吧熄滅屏幕,如:如何保持圖像對齊窗口的右側,而不管窗口的大小如何調整?

enter image description here

在那個例子中,我們應該看到的圖像的一個完整的電話。

我已經定義了以下網格佈局:

<Grid Background="White" > 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="23" /> 
     <ColumnDefinition Width="166" /> 
     <ColumnDefinition Width="473" /> 
     <ColumnDefinition Width="330" /> 
    </Grid.ColumnDefinitions> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="50" /> 
     <RowDefinition Height="35" /> 
     <RowDefinition Height="35" /> 
     <RowDefinition Height="35" /> 
     <RowDefinition Height="50" /> 
     <RowDefinition Height="*" /> 
    </Grid.RowDefinitions> 

    <!-- some irrelevant stuff removed --> 

    <Canvas Grid.Column="3" HorizontalAlignment="Right" > 

     <Image HorizontalAlignment="Left" Name="imgLogo" Stretch="Uniform" VerticalAlignment="Center" Width="45" Height="45" Margin="30,135,0,0" Canvas.ZIndex="99" Canvas.Left="0" Canvas.Top="-7" /> 
     <Image Source="/Resources/Images/MobileBrandingSample.png" Height="634" Width="316" HorizontalAlignment="Left" Margin="0,14,0,0" Name="imgPhone" Stretch="Uniform" VerticalAlignment="Top" /> 
     <Label Canvas.Left="80" Canvas.Top="127" Content="" Height="20" Name="lblCompanyName" Width="169" FontSize="15" Padding="0,0,0,0" /> 

     <Label Canvas.Left="80" Canvas.Top="150" Height="20" Name="lblPhoneNumber" Width="160" FontSize="12" Padding="0,0,0,0"> 
      <TextBlock Name="tbPhoneNumberLabel" Text="" TextDecorations="Underline" Foreground="#35B6E5" Width="160"></TextBlock> 
     </Label> 
    </Canvas> 

</Grid> 

有了這個,imgPhone右對齊,但是當我調整窗口的大小imgPhone熄滅屏幕。不管窗口的大小如何調整,我需要保持imgPhone停靠在屏幕右側?

+1

您確實需要使用Canvas嗎? – sexta13

+0

我需要保持imgLogo和標籤絕對定位在imgPhone上。這適用於Canvas。如果還有另一種更好的方式,我願意接受建議。 – DaveDev

+0

你能張貼你假裝的最終結果嗎?我可能是錯的,但如果你使用Grid並在Grid.Row = 0中設置imgPhone,Grid.Column = 0,然後將標籤設置爲相同的(Grid.row = 0,grid.column = 0),他們將重疊圖像! – sexta13

回答

0

溝渠的畫布,使用一個內部網格的Dockpanel,停靠整個很多的權利,並在網格中的絕對大小將保持你想要的東西相對於其他任何東西。

0

我試過這個....並得到了一個解決方案......也許不完全是你想要的,但我認爲你可以制定出一些需要的調整。

<Grid Background="White" > 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="Auto"></ColumnDefinition> 
     <ColumnDefinition Width="Auto"></ColumnDefinition> 
     <ColumnDefinition Width="*"></ColumnDefinition> 
    </Grid.ColumnDefinitions> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="Auto"></RowDefinition> 
     <RowDefinition Height="Auto"></RowDefinition> 
     <RowDefinition Height="Auto"></RowDefinition> 
     <RowDefinition Height="*"></RowDefinition> 
    </Grid.RowDefinitions> 

    <TextBlock Grid.Row="0" Grid.Column="0" Text="company name"></TextBlock> 
    <TextBlock Grid.Row="1" Grid.Column="0" Text="Phone number"></TextBlock> 
    <TextBlock Grid.Row="2" Grid.Column="0" Text="Logo name"></TextBlock> 
    <Button Grid.Row="3" Grid.Column="0" Content="Upgrade branding"></Button> 

    <TextBox Grid.Row="0" Grid.Column="1"></TextBox> 
    <TextBox Grid.Row="1" Grid.Column="1"></TextBox> 
    <Button Grid.Row="2" Grid.Column="1" Content="Load logo"></Button> 

    <Image Grid.Column="2" Grid.RowSpan="4" HorizontalAlignment="Right" Source="C:\Users\somonteiro\Desktop\Montagens\somonteiro.jpg"></Image> 

</Grid> 
相關問題