我有一个依赖属性,我想在图表上显示。
namespace ViewModels
{
public partial class MyVM: DependencyObject
{
public Double TotalPowerSoFar
{
get { return (Double)GetValue(TotalPowerSoFarProperty); }
set { SetValue(TotalPowerSoFarProperty, value); }
}
// Using a DependencyProperty as the backing store for GroupReadingsBy. This enables animation, styling, binding, etc...
public static readonly DependencyProperty TotalPowerSoFarProperty =
DependencyProperty.Register("TotalPowerSoFar", typeof(Double), typeof(EstimateVM), new UIPropertyMetadata(0.0));
TotalPowerSoFar=5.0;
}
}
我想我会做这样的事情:
<UserControl x:Class="Workspace"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:DV="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
xmlns:DVC="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<DVC:Chart Name="mcChart" Foreground="DarkBlue" Title="Area Chart" LegendTitle="Month Rating" >
<DVC:Chart.Series>
<DVC:ColumnSeries DependentValueBinding ="{Binding EstimatedTotalPower}"/>
</DVC:Chart.Series>
</DVC:Chart>
</Grid>
但据我了解,绑定是错误的。有什么帮助吗?