0

問題は、画像が画面の右側に固定されていないため、画面のサイズを変更すると画像が画面からはみ出すことです。

ここに画像の説明を入力

その例では、完全な電話の画像が表示されます。

次のグリッド レイアウトが定義されています。

<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ウィンドウのサイズ変更に関係なく、画面の右側にドッキングし続けるには何が必要ですか?

4

2 に答える 2

0

Canvas を捨てて、内部に Grid がある Dockpanel を使用し、すべてを正しくドッキングすると、グリッド内の絶対的なサイズ設定により、他のすべてのものに対して必要な場所に物が保持されます。

于 2013-10-18T10:24:41.827 に答える
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>
于 2013-10-18T10:26:01.447 に答える