我有一个作为主表的数据网格和一个用于详细显示的饼图。我在主表中有一个服务器列表及其 ServerID,如下所示 -
我的详细信息表是
当我单击相应的服务器 ID 时,我想在饼图中显示 RAM 的最新值(取决于 RAM_ID)- 已使用和可用。
例如,服务器 1 的值将显示为(来自 Ram_ID)
服务器 2
& 用于服务器 3
我尝试过的,
public override void OnApplyTemplate()
{
using (DB_Entities db = new DB_Entities())
{
var ramRow = db.UsageRAMs.OrderByDescending(c => c.ID).First();
var Ram = new List<UsageRAM>() { new UsageRAM() { name = "Used" , value = ramRow.Used },
new UsageRAM() { name = "Available" , value = ramRow.Available}};
this.ramViewSource = (CollectionViewSource)this.FindResource("ramView");
ramViewSource.Source = Ram;
}
base.OnApplyTemplate();
}
XAML
<customControls:LabeledPieChart x:Name="labeledPieChartRAM" BorderBrush="Transparent" Margin="2,10,35,27" Grid.RowSpan="3" Grid.Column="1">
<customControls:LabeledPieChart.LegendStyle>
<Style TargetType="dv:Legend">
<Setter Property="Width" Value="0" />
</Style>
</customControls:LabeledPieChart.LegendStyle>
<customControls:LabeledPieChart.Series>
<customControls:LabeledPieSeries x:Name="labeledPieSeriesRAM"
ItemsSource="{Binding Source={StaticResource ramView}}"
PieChartLabelStyle="{StaticResource pieChartLabelStyle}"
PieChartLabelItemTemplate="{StaticResource pieChartLabelDataTemplate}"
IndependentValuePath="name" DependentValuePath="value" IsSelectionEnabled="True"
LabelDisplayMode="ArcMidpoint" />
</customControls:LabeledPieChart.Series>
</customControls:LabeledPieChart>
输出
上述代码的输出显示了详细信息表中的最新值,即它采用 RAM_ID 8 中的值,但在选择时我需要每个服务器的值。如何做到这一点?好心的帮助