0

コントロールDockPanelの下部に (不透明度を使用して) を配置したい:幅は現在の幅と同じにする必要があります。ImageDockPanelImage

XAML は次のとおりです。

<Window
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Grid>
    <Image Source="..." />

    <DockPanel VerticalAlignment="Bottom" LastChildFill="True" Opacity="0.5">
      <Button Content="Play" />
      <ProgressBar Value="50" Maximum="100" Height="40" />
    </DockPanel>
  </Grid>
</Window>

この XAML の場合: の幅は幅DockPanelと等しくありませんImage。幅はDockPanelwidth に設定されWindowます。

4

1 に答える 1

1

これはあなたが必要とするものです(バインディング付き)

<Image Source="..." Name=myImg/> 


<DockPanel Width="{Binding ElementName=myImg, Path=ActualWidth}" VerticalAlignment="Bottom" LastChildFill="True" Opacity="0.5" > 

バインドなしで可能な解決策は

<Viewbox>
        <Grid>
            <Image Source=... /> 

            <DockPanel VerticalAlignment="Bottom" LastChildFill="True" Opacity="0.5" > 
              <Button Content="Play" /> 
              <ProgressBar Value="50" Maximum="100" Height="40" /> 
            </DockPanel>
        </Grid>
    </Viewbox>
于 2012-03-28T08:57:10.623 に答える