Binding to Count attribute of ObservableCollection Silverlight
I have an ObservableCollection and a Datagrid.
What I do is:
datagrid.ItemsSource = observableCollection1;
And I need to make a binding to the observableCollection.Count attribute.
I tryed:
Tag="{Binding ObservableCollection.Count}"
Tag = "{Binding Count}"
Tag = "{Binding .Count}"
Tag = "{Binding开发者_C百科 Path=.Count}"
But it dosen't work. :(
Help
Tag="{Binding ItemsSource.Count, RelativeSource={RelativeSource Self}}"
Tags must be bound to strings. You should create a converter to cast it from a numeric value to string. If you only see 0 this is probably the resolution. This would be the first thing I would explore though you would expect it cast it using ToString().
See this for how to do it:
http://forums.silverlight.net/forums/p/184232/419976.aspx
What I do is take the selected item from the datagrid attribute SelectedItem and with that I don't have to put tags to buttons ;)
精彩评论