2016-06-21 74 views
0

返回0,我在UWP一个gridview,做工精细绑定到GridView.Items.Count总是UWP

<GridView x:Name="my_gridview" ItemsSource="{Binding CollectionItem, Mode=TwoWay}"/> 

并有秀文本块CollectionItem

的计数
<TextBlock Text="{Binding ElementName=my_gridview, Path=Items.Count, RelativeSource={RelativeSource Self}}"/> 

问题:即使我们在gridview中有很多项目,textblock始终显示0!

+1

你尝试''?除此之外,在ItemsSource绑定上设置Mode = TwoWay是没有意义的。 – Clemens

回答

2

更好的直接绑定到源集合:

<TextBlock Text="{Binding CollectionItem.Count}" /> 
+0

再次感谢 – FatemehEbrahimiNik

0

您在同一时间设置了ElementNameRelativeSource(这一个是假的),后者可能会覆盖前者或导致冲突错误,请检查Output窗口并且会出现绑定错误。

+0

是的,我尝试用干净这一行RelativeSource = {RelativeSource Self}但不再工作 – FatemehEbrahimiNik

+0

@nik:检查输出,它会告诉你什么是错的。 –

+0

请帮助我真的我不知道我在做什么? – FatemehEbrahimiNik