【问题标题】:Binding Path hierarchy绑定路径层次结构
【发布时间】:2018-01-31 10:15:21
【问题描述】:

我开发了一个带有测量对象的用户控件。每个测量对象都有一个单元对象列表,每个单元对象都有一个测站对象列表。

用户控件为每个站生成一个文本框。目前我将每个 Station 的 DataContext 设置为某个 Station,并将 BindingPath 设置为我的 Value Member。

这可行,但是当我尝试显示不同的测量时,我必须将绑定设置为新测量的站。

我想实现,设置一个 BindingPath,只有 Usercontrol 的 DataContext 必须设置为新的 Measurement 并且所有文本框都采用新的 Bindings。

这可能吗?

【问题讨论】:

  • 做测量,小区和站对象实现INotifyPropertyChanged?

标签: wpf binding


【解决方案1】:

我不确定我是否完全理解您的问题,但据我猜测,您可能正在寻找这样的东西:

<ItemsControl ItemsSource="{Binding Path=Cells}">
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <ItemsControl ItemsSource="{Binding Path=Stations}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <TextBox Text="{Binding Value}" />
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-17
    • 2013-10-08
    • 1970-01-01
    相关资源
    最近更新 更多