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宽度。DockPanel宽度设置为宽度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 回答