我有一个充满小用户控件的窗口,每个用户控件都有一个3行网格。现在,当我缩小窗口时,行中的内容会被切割(垂直)。但是第1行中的内容是最重要的位,第0行的内容稍微不那么重要,第2行的内容是最不重要的,所以我想这样做,当缩小时,第2行先消失,然后排0。 有什么建议?
编辑:这是我的小用户控件的xaml:
<Grid x:Name="suzi">
<Grid.RowDefinitions>
<RowDefinition Height="*" MinHeight="5"/>
<RowDefinition Height="*" />
<RowDefinition Height="*" MinHeight="10"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="Azure" Background="Black" Content="D00" FontSize="15" Name="LabelShow">
<Label.ToolTip>
<ToolTip>
<StackPanel>
<TextBlock FontWeight="Bold">Ime naprave</TextBlock>
<TextBlock x:Name="FullName"></TextBlock>
</StackPanel>
</ToolTip>
</Label.ToolTip>
</Label>
<TextBox x:Name="tbSV" Grid.Row="2" Background="Black" IsHitTestVisible="False" HorizontalAlignment="Center" Text="{Binding ElementName=Slider, Path=Value, StringFormat=0}" Foreground="Azure" VerticalAlignment="Top" FontSize="15" BorderBrush="Black" HorizontalContentAlignment="Center" RenderTransformOrigin="0.488,1.846"/>
<Rectangle x:Name="af1" Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=ActualWidth}"
Height="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=ActualHeight}"
Stroke="{Binding Stroke}" HorizontalAlignment="Center" VerticalAlignment="center" Grid.RowSpan="3" StrokeThickness="1" />
<Slider Style="{StaticResource StyleForSlider}" Name="Slider" Margin="5,0,5,0" Grid.Row="1" VerticalContentAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Stretch" Grid.RowSpan="1" TickFrequency="100" Maximum="100" ValueChanged="Slider_ValueChanged" IsHitTestVisible="False" Focusable="False" />
</Grid>
Edit2:到目前为止我正在尝试:
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
double neki = suzi.ActualHeight;
if (neki <= 75)
{
LabelShow.Visibility = Visibility.Hidden;
tbSV.Visibility = Visibility.Hidden;
}
else
{
LabelShow.Visibility = Visibility.Visible;
tbSV.Visibility = Visibility.Visible;
}
但它只是不能正常工作,因为我需要滑块行扩展隐藏的那些......(而这里我一次隐藏一个项目而不是整行,但这是我最接近的到目前为止......)
答案 0 :(得分:0)
您可以为每一行提供最小尺寸,这对您来说足够了:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" MinHeight="10"/>
<RowDefinition Height="Auto" MinHeight="20"/>
</Grid.RowDefinitions>
</Grid>
我没有看到任何改变默认行为的方法,它遵循通常的左上角到右下角的顺序。