0
我有一个ListView和一个dataTemplate,我需要绑定到3个不同的来源,具有相同的索引。我认为我必须在XAML中完全执行此操作,因为源(chart
)仅存在于xaml中。我使用MVVM模式。”
我已经记下了它是如何‘应该’的工作,该指数i
是公共密钥。将多个源绑定到ListView
<ListView ItemsSource="{Binding ???}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel>
<!-- Small rectangle filled with the same color as the corresponding line -->
<Rectangle
Height="10"
Width="10"
Fill="{Binding ElementName=chart, Path=Series[i].LineStroke}" />
<!-- The title of the corresponding line -->
<TextBlock
x:Name="Title"
Text="{Binding ElementName=chart, Path=Series[i].DataSeries.Title}" />
<!-- The actual value of the corresponding line on the current position-->
<TextBlock
x:Name="Value"
Text="{Binding ElementName=chart, Path=Behaviour.Behaviours[0].CurrentPoints[i].Y}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
您正在使用MVVM ..所以你不应该为这种情况创建一个** ViewModel **?包含Series和Behavior的类。然后使用此ViewModel作为ListView的绑定源。 – Damb 2011-04-01 07:42:19
我有一个ViewModel仅为图表控件提供数据,但图表创建颜色,只有图表知道当前选择了哪个Y点。图表只在视图中是已知的,所以? – chriszero 2011-04-01 07:50:55