首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >动态WpfToolkit图表DependentValue

动态WpfToolkit图表DependentValue
EN

Stack Overflow用户
提问于 2014-04-10 03:41:01
回答 2查看 351关注 0票数 0

我不知道这是否可行,但我会试一试。我有一个关于以下代码的问题:

代码语言:javascript
运行
复制
      <charts:Chart Grid.Row="0" Height="262" HorizontalAlignment="Left" 
              Title="Column Series Demo" 
            VerticalAlignment="Bottom" Width="360">
                <charts:ScatterSeries
DependentValueBinding= "{Binding ElementName=XAxisCb,Path=SelectedItem}"
IndependentValueBinding= "{Binding ElementName=YAxisCb,Path=SelectedItem}"
x:Name="Series" 
DataPointStyle="{StaticResource RingChartSymbolStyle}" 
ItemsSource="{Binding Patterns}"  />
            </charts:Chart>

  <ComboBox x:Name="XAxisCb"  ItemsSource="{Binding DependentNamesX}" SelectedItem="{Binding DependentNameX,Mode=TwoWay}"/>
  <ComboBox x:Name="YAxisCb" ItemsSource="{Binding InDependentNamesY}" SelectedItem="{Binding InDependentNameY,Mode=TwoWay}"/>

public class Pattern
{
  public List<IFeature> Features
        {
            get { return _features; }
            set { _features = value; }
        }
}

 public interface IFeature
    {
         string Name { get; set; }
        double Value { get; set; }
    }

如果我有类Point,我只需将X轴设置为属性X,将Y轴设置为属性Y。现在我有了包含List<IFeature>Pattern类,这意味着属性列表。例如,如何将DependentValueBinding和IndependentValueBinding设置为从特征到X (Pattern.Features)的第一个属性,以及将第二个属性设置为Y(每个模式中的Patter.Features1?

例如:

代码语言:javascript
运行
复制
 DependentValueBinding= "{Binding Features[0]}"
 IndependentValueBinding= "{Binding Features[1] }"
EN

回答 2

Stack Overflow用户

发布于 2014-04-10 04:14:58

看起来你可以使用数据模板,尽管这个问题有点不清楚。

在窗口的资源中:

代码语言:javascript
运行
复制
<DataTemplate x:Key="PatternsDataTemplate">
 <ComboBox ItemsSource="{Binding Features}" ItemTemplate="{StaticResource FeaturesDataTemplate}"/>
</DataTemplate>

<DataTemplate x:Key="FeaturesDataTemplate">
  <Grid>
    <TextBlock Text="{Binding Name}"/>
    <TextBlock Text="{Binding Value}"/>
  </Grid>
</DataTemplate>

然后在图表之后你可以做这样的事情。

代码语言:javascript
运行
复制
<ComboBox ItemsSource="{Binding Patterns}" ItemTemplate="{StaticResource PatternsDataTemplate}"/>

我不太确定你是否想要一个组合框,或者你想要做什么,但是如果我对这个问题理解的足够多,这篇文章应该会给你一个大概的概念

票数 0
EN

Stack Overflow用户

发布于 2014-04-10 04:47:12

解决方案非常简单:)

代码语言:javascript
运行
复制
 IndependentValueBinding="{Binding Features[0].Value}"
 DependentValueBinding="{Binding Features[1].Value}"

编辑:我认为我可以通过使用Properties或Converter参数来获得实际的元素,但这两个参数都受到限制。所以这不是最终的解决方案。我不知道如何绑定依赖于UI的Featuresi。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22972446

复制
相关文章

相似问题

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