使用 WPF 定位多个图表
Positioning multiple charts using WPF
我有一个图表,可以在更改组合框选择时从本地数据库查询数据。工作正常。但是,我想在其下方添加另一个图表。我该怎么做?
<Grid x:Name="grid" >
<TabControl HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" >
<TabItem Header="Settings">
<Grid x:Name="tabItemSettings" Background="#FFE5E5E5">
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<DVC:Chart Name="mcChartActivity"
Width="1400" Height="500"
Background="LightBlue"
Foreground="DarkBlue"
Title="Statistics" >
<DVC:Chart.Series>
<DVC:ColumnSeries
Title="Area Chart"
IndependentValuePath="Key"
DependentValuePath="Value">
</DVC:ColumnSeries>
</DVC:Chart.Series>
</DVC:Chart>
</ScrollViewer>
</Grid>
</TabItem>
</TabControl>
</Grid>
只需添加 RowDefinitions
并在您的控件上设置附加的 Grid.Row
属性 以指示它们应显示在哪一行。您还可以在 RowDefintion
中指定 MinHeight
、Height
或 MaxHeight
。如果要按列显示图表,请改为添加 ColumnDefintions
。
<Grid x:Name="grid">
<TabControl HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" >
<TabItem Header="Settings">
<Grid x:Name="tabItemSettings" Background="#FFE5E5E5">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<ScrollViewer Grid.Row="0" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<DVC:Chart Name="mcChartActivity"
Width="1400" Height="500"
Background="LightBlue"
Foreground="DarkBlue"
Title="Statistics" >
<DVC:Chart.Series>
<DVC:ColumnSeries
Title="Area Chart"
IndependentValuePath="Key"
DependentValuePath="Value">
</DVC:ColumnSeries>
</DVC:Chart.Series>
</DVC:Chart>
</ScrollViewer>
<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<!-- ...your other chart. -->
</ScrollViewer>
</Grid>
</TabItem>
</TabControl>
</Grid>
我有一个图表,可以在更改组合框选择时从本地数据库查询数据。工作正常。但是,我想在其下方添加另一个图表。我该怎么做?
<Grid x:Name="grid" >
<TabControl HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" >
<TabItem Header="Settings">
<Grid x:Name="tabItemSettings" Background="#FFE5E5E5">
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<DVC:Chart Name="mcChartActivity"
Width="1400" Height="500"
Background="LightBlue"
Foreground="DarkBlue"
Title="Statistics" >
<DVC:Chart.Series>
<DVC:ColumnSeries
Title="Area Chart"
IndependentValuePath="Key"
DependentValuePath="Value">
</DVC:ColumnSeries>
</DVC:Chart.Series>
</DVC:Chart>
</ScrollViewer>
</Grid>
</TabItem>
</TabControl>
</Grid>
只需添加 RowDefinitions
并在您的控件上设置附加的 Grid.Row
属性 以指示它们应显示在哪一行。您还可以在 RowDefintion
中指定 MinHeight
、Height
或 MaxHeight
。如果要按列显示图表,请改为添加 ColumnDefintions
。
<Grid x:Name="grid">
<TabControl HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" >
<TabItem Header="Settings">
<Grid x:Name="tabItemSettings" Background="#FFE5E5E5">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<ScrollViewer Grid.Row="0" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<DVC:Chart Name="mcChartActivity"
Width="1400" Height="500"
Background="LightBlue"
Foreground="DarkBlue"
Title="Statistics" >
<DVC:Chart.Series>
<DVC:ColumnSeries
Title="Area Chart"
IndependentValuePath="Key"
DependentValuePath="Value">
</DVC:ColumnSeries>
</DVC:Chart.Series>
</DVC:Chart>
</ScrollViewer>
<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<!-- ...your other chart. -->
</ScrollViewer>
</Grid>
</TabItem>
</TabControl>
</Grid>