【发布时间】:2011-03-07 20:12:54
【问题描述】:
我在 DataTemplate 中有一个组合框,如下所示:
<ComboBox x:Name="cboImages" Grid.Row="1" Grid.Column="1" SelectedItem="{Binding XPath=ImageName, Path=SelectedItem.Content, Mode=TwoWay}" IsSynchronizedWithCurrentItem="True" >
<ComboBoxItem>Image1.jpg</ComboBoxItem>
<ComboBoxItem>Image2.jpg</ComboBoxItem>
<ComboBoxItem>Image3.jpg</ComboBoxItem>
</ComboBox>
我想要实现的是使用组合框的SelectedItem 更新我的 XML 数据源的属性 (ImageName)。
任何线索上面的代码有什么问题。 提前致谢。
【问题讨论】:
-
好的,我已经设法解决了这个问题,但现在我有另一个问题。我有三个组合框显示来自同一源文件(xml)的图像。用户从每个组合框中选择图像作为选择 1、2 3。我将这 3 个选择绑定到产品数据源(xml 文件)中的三个不同字段作为 Logo1、Logo2、Logo3),但是所有三个组合框都以某种方式绑定在一起.如果我从选择 1 中选择图像,则其他两个组合框将使用选择 1 进行更新。