如何让Flyout的宽度自适应应用程序的宽度?

5

我在我的Metro风格应用程序中使用Flyouts,该应用程序使用MahApps Metro包

<Controls:MetroWindow.Flyouts>
    <Controls:FlyoutsControl>
        <Controls:Flyout Header="INSTELLINGEN" Position="Left" Width="600" Theme="Dark">
            some content
        </Controls:Flyout>
    </Controls:FlyoutsControl>
</Controls:MetroWindow.Flyouts>

这很好,但是现在我想要一个 Flyout 占据整个应用程序的宽度,即使用户调整了大小。基本上我想要 Width="*" 但这不起作用。


2
如果省略 PositionWidth 会发生什么? - Patrick Hofman
1个回答

7

这里有一个针对最新的Alpha版本(0.15)有效的示例。

只需设置MarginWidth,即可得到所需的内容。

  <controls:MetroWindow.Flyouts>
    <controls:FlyoutsControl>
      <controls:Flyout Header="INSTELLINGEN"
                       Position="Left"
                       Margin="0 0 100 0"
                       Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=controls:MetroWindow}, Path=ActualWidth}"
                       Theme="Dark">
      </controls:Flyout>
    </controls:FlyoutsControl>
  </controls:MetroWindow.Flyouts>

好的回答。宽度的绑定给了我一个想法,可以让我的应用程序具有响应性。 - Mark

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接