首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >绑定到Xceed图

绑定到Xceed图
EN

Stack Overflow用户
提问于 2014-08-30 07:35:11
回答 1查看 1.5K关注 0票数 2

我试图绑定到Xceed中的图形控件(Wpf工具包extended )。

然而,文献资料让我更加困惑.

上面写着

可以使用DataPoints属性直接设置序列的数据点,但也可以通过将series类的DataPointsSource属性绑定到源,然后使用BindingInfo对象填充DataPointBindings来设置它们,后者存储DataPoint类的单个属性的绑定信息。使用BindingInfo.Binding属性为给定的DataPoint属性(即内容、标签、X或Y)设置绑定对象,并使用BindingInfo.PropertyName属性(其类型为DataPointPropertyName)设置要使用绑定的属性。

所以,我的XAML是

代码语言:javascript
复制
<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>

我背后的代码是

代码语言:javascript
复制
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; }

图表显示,但是,从来没有任何数据。

那么,如何绑定来处理我的图形呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-09-27 13:55:50

这样就行了

代码语言:javascript
复制
  <!-- ... -->

  <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>
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25580129

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档