【发布时间】:2012-08-30 06:18:09
【问题描述】:
我希望实现像普通媒体播放器一样的效果,带有 eq 或 tracklist 面板,只需单击即可显示或更少显示。 主窗口应该根据显示的内容自动调整大小。 我想知道我是否必须关心手动指定大小或者有更清晰的解决方案。
<Window x:Class="WpfApplicationAnimation.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="Auto" Width="Auto" SizeToContent="WidthAndHeight">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Label Margin="5" Grid.Column="0" Grid.Row="0">Value 1:</Label>
<Label Margin="5" Grid.Column="0" Grid.Row="1">Value 2:</Label>
<Label Margin="5" Grid.Column="0" Grid.Row="2">Value 3:</Label>
<Button Margin="5" Click="Button_Click_1" Grid.Column="0" Grid.Row="3" Visibility="Hidden">Hello</Button>
<TextBox Name="txt1" Margin="5" Grid.Column="1" Grid.Row="0" MinWidth="100" />
<TextBox Margin="5" Grid.Column="1" Grid.Row="1" MinWidth="100" />
<TextBox Margin="5" Grid.Column="1" Grid.Row="2" MinWidth="100" />
</Grid>
我尝试设置 SizeToContent="WidthAndHeight" 但即使可见,按钮的内容也会占用所需的空间。
【问题讨论】:
-
您应该发布您尝试过的内容...或一些代码...
标签: wpf xaml resize panel visibility