绑定到伯爵在DataContext的项目 [英] Bind to Count of items in the DataContext

查看:89
本文介绍了绑定到伯爵在DataContext的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要绑定到我的DataContext中的项目数/数量。

I want to bind to the Count/amount of items within my DataContext.

我有一个对象,可以说其中有一个列表与LT人;地址> 作为一个属性。我想显示的地址量的那个人,即:5或6或其他情况而定。

I have an object, lets say person which has a List<address> as a property. I would like to display the amount of addresses for that person ie: 5 or 6 or whatever the case may be.

我试过 {绑定路径=#地址.Count之间} 和其他几个人,但是,这并不似乎工作。

I've tried {Binding Path=address#.Count} and a few others but that doesnt seem to work.

任何帮助将是AP preciated,谢谢。

Any help would be appreciated, thanks.

推荐答案

您需要将名称绑定属性,而不是它的类型。

You need to bind the name of the property, not its type.

C#:

public class Person
{
    ...
    public List<address> Addresses { get; set; }
    ...
}

XAML:

{Binding Addresses.Count}

假设你的的DataContext 是类型的对象

这篇关于绑定到伯爵在DataContext的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆