假设我有某种 LiveCharts 图表。当我调整窗口大小时,我需要窗口的长度和宽度之间的比例为 1x1。
XAML 代码:
<Grid Background="#f5f5f5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5" />
<ColumnDefinition />
<ColumnDefinition Width="5" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="5" />
<RowDefinition />
<RowDefinition Height="5" />
<RowDefinition Height="40"/>
<RowDefinition Height="5" />
</Grid.RowDefinitions>
<DockPanel Grid.Row="1" Grid.Column="1" Margin="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
<Label Content="Номер сечения:" Width="120" />
<Label Content="{Binding SliderValue}" Width="100" />
</StackPanel>
<lvc:CartesianChart DockPanel.Dock="Top" DisableAnimations="True" LegendLocation="Top">
<!-- Здесь какой-то график -->
</lvc:CartesianChart>
</DockPanel>
<DockPanel Grid.Row="3" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<StackPanel DockPanel.Dock="Left">
<Slider Value="{Binding SliderValue, Mode=TwoWay}" Margin="5" SelectionStart="0" Minimum="0" Maximum="299" TickPlacement="BottomRight" TickFrequency="1" IsSnapToTickEnabled="True" IsSelectionRangeEnabled="True" />
</StackPanel>
</DockPanel>
</Grid>