我试图绑定到Xceed中的图形控件(Wpf工具包extended )。
然而,文献资料让我更加困惑.
上面写着
可以使用DataPoints属性直接设置序列的数据点,但也可以通过将series类的DataPointsSource属性绑定到源,然后使用BindingInfo对象填充DataPointBindings来设置它们,后者存储DataPoint类的单个属性的绑定信息。使用BindingInfo.Binding属性为给定的DataPoint属性(即内容、标签、X或Y)设置绑定对象,并使用BindingInfo.PropertyName属性(其类型为DataPointPropertyName)设置要使用绑定的属性。
所以,我的XAML是
<StackPanel.Resources>
<loc:BackupResultsViewModel x:Key="MyVm" />
<CollectionViewSource x:Key="StatusCollection" Source="{Binding Source={StaticResource MyVm}, Path=MyData}" />
</StackPanel.Resources>
<xctk:Chart Height="30" Width="300" ShowLegend="True" >
<xctk:Chart.Legend>
<xctk:Legend Dock="Left" AllowResize="False" AllowDock="True" AllowMove="True" Title="Legend"/>
</xctk:Chart.Legend>
<xctk:Chart.Areas>
<xctk:Area Title="Overall status" >
<xctk:Area.XAxis>
<xctk:Axis ShowAxisLabel="False" ShowTickLabels="False" ShowTicks="False"/>
</xctk:Area.XAxis>
<xctk:Area.YAxis>
<xctk:Axis ShowAxisLabel="False" ShowTickLabels="False" ShowTicks="False"/>
</xctk:Area.YAxis>
<xctk:Area.Series>
<xctk:Series Title="Overall status" DataPointsSource="{Binding Source={StaticResource StatusCollection}}">
<xctk:Series.Layout>
<xctk:PieLayout />
</xctk:Series.Layout>
<xctk:Series.DataPointBindings>
<xctk:BindingInfo PropertyName="Y">
<xctk:BindingInfo.Binding>
<Binding/>
</xctk:BindingInfo.Binding>
</xctk:BindingInfo>
<xctk:BindingInfo PropertyName="X">
<xctk:BindingInfo.Binding>
<Binding/>
</xctk:BindingInfo.Binding>
</xctk:BindingInfo>
<xctk:BindingInfo PropertyName="Label">
<xctk:BindingInfo.Binding>
<Binding/>
</xctk:BindingInfo.Binding>
</xctk:BindingInfo>
</xctk:Series.DataPointBindings>
</xctk:Series>
</xctk:Area.Series>
</xctk:Area>
</xctk:Chart.Areas>
</xctk:Chart>我背后的代码是
public GraphViewModel()
{
this.Title = title;
var data = new DataPointsList<DataPoint>();
data.Add(new DataPoint(0, 8, "0"));
data.Add(new DataPoint(1, 4, "1"));
data.Add(new DataPoint(2, 3, "2"));
data.Add(new DataPoint(3, 2, "3"));
this.MyData = data;
}
public DataPointsList<DataPoint> MyData { get; set; }图表显示,但是,从来没有任何数据。
那么,如何绑定来处理我的图形呢?
发布于 2014-09-27 13:55:50
这样就行了
<!-- ... -->
<xctk:BindingInfo PropertyName="Y">
<xctk:BindingInfo.Binding>
<Binding Path="Y"/> <!--NOTE-->
</xctk:BindingInfo.Binding>
</xctk:BindingInfo>
<xctk:BindingInfo PropertyName="X">
<xctk:BindingInfo.Binding>
<Binding Path="X"/><!--NOTE-->
</xctk:BindingInfo.Binding>
</xctk:BindingInfo>
<xctk:BindingInfo PropertyName="Label">
<xctk:BindingInfo.Binding>
<Binding Path="Label"/><!--NOTE-->
</xctk:BindingInfo.Binding>
</xctk:BindingInfo>
</xctk:Series.DataPointBindings>https://stackoverflow.com/questions/25580129
复制相似问题