我不知道这是否可行,但我会试一试。我有一个关于以下代码的问题:
<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?
例如:
DependentValueBinding= "{Binding Features[0]}"
IndependentValueBinding= "{Binding Features[1] }"
发布于 2014-04-10 04:14:58
看起来你可以使用数据模板,尽管这个问题有点不清楚。
在窗口的资源中:
<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>
然后在图表之后你可以做这样的事情。
<ComboBox ItemsSource="{Binding Patterns}" ItemTemplate="{StaticResource PatternsDataTemplate}"/>
我不太确定你是否想要一个组合框,或者你想要做什么,但是如果我对这个问题理解的足够多,这篇文章应该会给你一个大概的概念
发布于 2014-04-10 04:47:12
解决方案非常简单:)
IndependentValueBinding="{Binding Features[0].Value}"
DependentValueBinding="{Binding Features[1].Value}"
编辑:我认为我可以通过使用Properties或Converter参数来获得实际的元素,但这两个参数都受到限制。所以这不是最终的解决方案。我不知道如何绑定依赖于UI的Featuresi。
https://stackoverflow.com/questions/22972446
复制相似问题