0

Допустим у меня есть какой-то график 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>
 &lt;DockPanel Grid.Row=&quot;1&quot; Grid.Column=&quot;1&quot; Margin=&quot;5&quot; HorizontalAlignment=&quot;Stretch&quot; VerticalAlignment=&quot;Stretch&quot;&gt;
     &lt;StackPanel DockPanel.Dock=&quot;Top&quot; Orientation=&quot;Horizontal&quot;&gt;
         &lt;Label Content=&quot;Номер сечения:&quot;        Width=&quot;120&quot; /&gt;
         &lt;Label Content=&quot;{Binding SliderValue}&quot; Width=&quot;100&quot; /&gt;
     &lt;/StackPanel&gt;

     &lt;lvc:CartesianChart DockPanel.Dock=&quot;Top&quot; DisableAnimations=&quot;True&quot; LegendLocation=&quot;Top&quot;&gt;
          &lt;!-- Здесь какой-то график --&gt;
     &lt;/lvc:CartesianChart&gt;

 &lt;/DockPanel&gt;

 &lt;DockPanel Grid.Row=&quot;3&quot; Grid.Column=&quot;1&quot; HorizontalAlignment=&quot;Stretch&quot; VerticalAlignment=&quot;Stretch&quot;&gt;
     &lt;StackPanel DockPanel.Dock=&quot;Left&quot;&gt;
         &lt;Slider Value=&quot;{Binding SliderValue, Mode=TwoWay}&quot; Margin=&quot;5&quot; SelectionStart=&quot;0&quot; Minimum=&quot;0&quot; Maximum=&quot;299&quot; TickPlacement=&quot;BottomRight&quot; TickFrequency=&quot;1&quot; IsSnapToTickEnabled=&quot;True&quot; IsSelectionRangeEnabled=&quot;True&quot; /&gt;
     &lt;/StackPanel&gt;
 &lt;/DockPanel&gt;

</Grid>

1 Answers1

0

Получилось с помощью комментария:

<Viewbox Stretch="Uniform">
     <lvc:CartesianChart Width="500" Height="500" DisableAnimations="True" LegendLocation="Top">
     <!-- Здесь какой-то график -->
     </lvc:CartesianChart>
</Viewbox>