問題是圖像不固定在屏幕的右側,所以當我調整屏幕形象吧熄滅屏幕,如:如何保持圖像對齊窗口的右側,而不管窗口的大小如何調整?
在那個例子中,我們應該看到的圖像的一個完整的電話。
我已經定義了以下網格佈局:
<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
停靠在屏幕右側?
您確實需要使用Canvas嗎? – sexta13
我需要保持imgLogo和標籤絕對定位在imgPhone上。這適用於Canvas。如果還有另一種更好的方式,我願意接受建議。 – DaveDev
你能張貼你假裝的最終結果嗎?我可能是錯的,但如果你使用Grid並在Grid.Row = 0中設置imgPhone,Grid.Column = 0,然後將標籤設置爲相同的(Grid.row = 0,grid.column = 0),他們將重疊圖像! – sexta13