我有一个工具栏,我想让它的项目在窗口调整大小时叠加在一起(就好像它是在Bootstrap网格中,如果它是HTML)...
<Grid VerticalAlignment="Top" x:Name="TopBar" Margin="0,0,0.35,0" Opacity="0.8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<textbox Grid.Column="0" content="text"/>
<ToolBarPanel HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal" Grid.Column="1">
<WrapPanel Orientation="Horizontal" Width="500">
<Button content="toolbar_item"></Button>
<Button content="toolbar_item"></Button>
<Button content="toolbar_item"></Button>
<Button content="toolbar_item"></Button>
<Button content="toolbar_item"></Button>
<Button content="toolbar_item"></Button>
</WrapPanel>
</ToolBarPanel>
</Grid>
然而,在此设置下,按钮会在加载时堆叠,但它们不动态,它们不会继续堆叠,因为窗口变小,它们只是溢出。有没有办法让这种情况发生?
答案 0 :(得分:0)
试试吧。您可以使用ViewBox
来实现您所说的效果。请查看以下代码。
<Grid VerticalAlignment="Top" x:Name="TopBar" Margin="0,0,0.35,0" Opacity="0.8">
<Viewbox>
<ToolBarPanel HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal" >
<WrapPanel>
<Button Content="toolbar_item"></Button>
<Button Content="toolbar_item"></Button>
<Button Content="toolbar_item"></Button>
<Button Content="toolbar_item"></Button>
<Button Content="toolbar_item"></Button>
<Button Content="toolbar_item"></Button>
</WrapPanel>
</ToolBarPanel>
</Viewbox>
</Grid>